【发布时间】:2016-09-23 23:13:33
【问题描述】:
我正在实现 dropzone um 页面,并且在每个 iamge 中我需要添加一个标题和描述,但是当我尝试发送多张照片时,不是每个请求或图像都有一个标题,而是给了我所有相同的名称。
我的代码:
$('#submit').on('click',function(e){
e.preventDefault();
myDropzone.processQueue();
});
Dropzone.autoDiscover = false;
// Dropzone class:
var myDropzone = new Dropzone("div#myId", {
url: "/products",
autoProcessQueue:false,
previewTemplate: "<div class=\"dz-preview dz-file-preview\">\n " +
"<div class=\"dz-image\"><img data-dz-thumbnail /></div>\n " +
"<input type=\"text\" id=\"title\" data-dz-title name=\"dz-title\">\n " +
"<input type=\"text\" id=\"url\" name=\"dz-url\">\n " +
" <div class=\"dz-details\">"
}).on("sending", function(file, xhr, formData) {
formData.append("title", $('#title').val());
});
【问题讨论】:
-
.on("sending", function(file, xhr, formData) { $( "#title" ).each(function() { formData.append("title", $( this ).val()); }); -
不行,试试吧。
标签: javascript php dropzone.js