【问题标题】:AngularJS: Upload picture to facebook graph api as multipart/formdataAngularJS:将图片作为 multipart/formdata 上传到 facebook graph api
【发布时间】:2015-10-06 04:59:50
【问题描述】:

我正在尝试使用中所示的方法将照片上传到 facebook https://developers.facebook.com/docs/graph-api/reference/user/photos/

如果照片已经在互联网上,我可以使用如下所示的 url 参数进行上传。

$scope.uploadPicture = function () {        
    FB.api(
        "/me/photos", 'post', {
            caption: "Testing uploadPicture",
            access_token: authFact.getAccessToken(),
            url: 'http://www.website.com/somejpg.jpg'
        },
        function (response) {
                if (response && !response.error) {
                    console.log(response);
                } 
            }
        );
    };

我希望能够将本地机器上的图片作为 multipart/form-data 发布。

有人能指出我正确的方向吗?

我的 html 是这样的

<form>
            <div class="form-group">
                <label for="fileInput">File input</label>
                <input type="file" id="fileInput">
                <p class="help-block">Example block-level help text here.</p>
            </div>
            <div class="form-group">
                <label for="itemName">Name: </label>
                <input type="text" class="form-control" id="itemName" placeholder="Enter Name here..">
            </div>
            <button type="submit" class="btn btn-default">Submit</button>
        </form>

【问题讨论】:

    标签: angularjs facebook facebook-graph-api


    【解决方案1】:

    尝试使用 source 而不是 url,url 用于已经在 Internet 上的文件。

    <input type="file" id="souce">
    

    【讨论】:

      猜你喜欢
      • 2013-04-19
      • 1970-01-01
      • 2011-12-12
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多