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')
不会被调用,因为我想找到file.path被上传到cloudinary。如何从悬浮窗文件上传到cloudinary
请帮
这是一个客户端代码?看起来它包含一些Node.js方法和你的证书,不应该在客户端显示。 您能否请您分享关于上下文的更多信息,以及哪些内容似乎有效,哪些不适用? –
使用browserify和backbone.js – vini
你不应该为你的客户端上传使用Node.js,而是使用[“jQuery upload plugin”](https://github.com/cloudinary/pkg-cloudinary-jquery-file而是上传)。此外,这个插件本身支持Dropzone(使用BlueImp) –