angular和Cloudinary直接上传400(错误请求)

时间:2017-06-22 22:34:46

标签: javascript angularjs cloudinary

我尝试使用以下代码上传到cloudinary时遇到400 bad request错误:

var file = /* your file */;
var cloud_name = 'your cloud_name';

var fd = new FormData();

fd.append('upload_preset', 'seller');
fd.append('file', file);

$http
    .post('https://api.cloudinary.com/v1_1/' + cloud_name + '/image/upload', fd, {
        headers: {
            'Content-Type': application/x-www-form-urlencoded,
            'X-Requested-With': 'XMLHttpRequest'
        }
    })
    .success(function (cloudinaryResponse) {

        // do stuff with cloudinary response
        // cloudinaryResponse = { public_id: ..., etc. }

    })
    .error(function (reponse) {


    });

我错过了什么?是否可以进行Cloudinary直接上传?

0 个答案:

没有答案