当我向队列添加文件时,我为每个文件生成一个文本输入。
是否可以将此输入值发送到服务器端?
我尝试将值添加到params对象中,如下所示:
up._options.request.params.description = id;
但它只发送最后一张图片的ID。
var up = new qq.FineUploaderBasic({
button: document.getElementById("addFiles"),
request: {
params: {
action: "upload",
},
endpoint: config.uploadURL,
},
validation: {
allowedExtensions: ["jpg", "jpeg", "png", "gif", "mkv", "mp4"],
},
autoUpload: false,
callbacks: {
onSubmit: function(id, fileName, response) {
var element = document.createElement("li");
element.setAttribute("id", "qImage-"+id);
element.setAttribute("class", "qImage");
$(".imagesList").prepend(element);
var out = "<div class='fileInfo'>";
out += "<span id='qCancel-"+id+"'>Cancel </span>";
out += fileName;
out += "</div>";
out += "<div class='fileData'>";
out += "<label for='fileDescription'>Description</label>";
out += "<input type='text' name='fileDescription' id='fileDescription'>";
out += "</div>";
$("#qImage-"+id).html(out);
$("#qCancel-"+id).on("click", function(){
up.cancel(id);
$("#qImage-"+id).remove();
});
up._options.request.params.description = id;
},
}
});
$('#startUpload').on("click", function(){
up.uploadStoredFiles();
//document.getElementById('queue-list').innerHTML = '';
});
$('#cancelUpload').on("click", function(){
up.cancelAll();
});
答案 0 :(得分:0)
为了扩展Ray的评论,我知道有两种方法。第一个可能是S3实现独有的,但我使用:
@Override
protected void onPostExecute(String result) {
if (result != null && !result.equals("")) {
try {
JSONArray jArray = new JSONArray();
JSONObject jObject = null;
try {
jObject = new JSONObject(result);
} catch (JSONException e) {
e.printStackTrace();
}
Iterator x = jObject.keys();
while (x.hasNext()){
String key = (String) x.next();
jArray.put(jObject.get(key));
}
for (int i = 0; i < jArray.length(); i++) {
JSONObject jRes = jArray.getJSONObject(i);
String title = jRes.getString("title");
Log.d("Article_title", title);
}
this.progressDialog.dismiss();
} catch (JSONException e) {
Log.e("JSONException", "Error: " + e.toString());
}
}
}
如果您希望将setParams与文件上传请求一起发送,请使用setParams。