【发布时间】:2016-11-28 08:40:07
【问题描述】:
var myDropzone = new Dropzone("#product-image-drpzone", {
// Prevents Dropzone from uploading dropped files immediately
autoProcessQueue: false,
addRemoveLinks: true,
autoQueue: false,
acceptedFiles: '.jpg,.png,.jpeg,.gif',
url: 'https://api.cloudinary.com/v1_1/something/image/upload', //put it in the main url file once done
maxfilesexceeded: function (file) {
ToasterWrapper.errorMessage('You have uploaded more than 4 images!', false);
return;
},
init: function () {
// You might want to show the submit button only when
// files are dropped here:
myDropzone = this;
var imagesArr = [];
cloudinary.config({
cloud_name: '',
api_key: '737587394822762',
api_secret: ''
});
this.processQueue();
this.on("addedfile", function (file) {
var myDropzone = this;
$(".dz-progress").remove();
console.log(file);
cloudinary.uploader.upload(file, function (result) {
console.log(result)
imagesArr.push(result.public_id);
},
{ use_filename: true });
$('#btn-remove').click(function () {
myDropzone.removeAllFiles();
});
});
this.on("sending", function (file, xhr, data) {
console.log(file.path);
});
}
});
this.on('sending') 没有被调用,因为我想找到要上传到 cloudinary 的 file.path。
请帮忙
【问题讨论】:
-
这是客户端代码吗?看起来它包含一些不应在客户端显示的 Node.js 方法和您的凭据。您能否分享更多有关上下文的信息以及哪些似乎有效,哪些无效?
-
将browserify与backbone.js一起使用
-
您不应该使用 Node.js 进行客户端上传,而是使用 "jQuery upload plugin"。此外,此插件原生支持 Dropzone(使用 BlueImp)
标签: javascript backbone.js browserify dropzone.js cloudinary