我正在尝试使用dropzone.js FAQ作为指南,以编程方式将现有图像添加到我的 dropzone :
// Add the existing image if it's there.
// headerDropzone is my dropzone (debug shows it as existing and initialized at this point.
var on_load_header = $( '[name="on_load_header_image"]' ).val();
var on_load_header_path = $( '[name="on_load_header_image_path"]' ).val();
if ( on_load_header ) {
// Hardcoded size value is just for testing, see my second question below.
var on_load_header_data = { name: on_load_header, size: 12345 };
// Call the default addedfile event handler
headerDropzone.options.addedfile.call( headerDropzone, on_load_header_data );
// And optionally show the thumbnail of the file:
headerDropzone.options. thumbnail.call( headerDropzone, on_load_header_data, on_load_header_path);
}
我的第一个问题是这不起作用。addedfile 事件不会触发(或者至少headerDropzone
不会触发 addedfile 处理程序),缩略图也是如此。
我的第二个问题/问题是:我必须提供文件大小吗?我可以在服务器端获取它,但如果我实际上不需要,我宁愿不这样做。