【发布时间】:2018-04-02 06:38:37
【问题描述】:
下面是我的代码:
let colNames = ['ID', 'Image', 'Title', 'Description'];
let colModel = [
{name: 'id', index: 'id', width: 30, editable: true, editoptions: {size: "30", maxlength: "50"}},
{
name: 'image',
index: 'image',
align: 'left',
editable: true,
edittype: 'file',
editoptions: {
multiple: true,
accept: ".jpg,.png,.jpeg",
enctype: "multipart/form-data"
},
width: 210,
align: 'center',
formatter: imageFormatter,
search: false
},
{name: 'image_title', index: 'image_title', width: 150, editable: true, editoptions: {size: "30", maxlength: "50"}},
{name: 'image_description', index: 'image_description', width: 150, editable: true, editoptions: {size: "30", maxlength: "50"}}
}
];
我正在使用 ajaxFileUpload,这是我上传的代码:
afterSubmit: function (response) {
if(response.responseJSON){
$.ajaxFileUpload({
url: fileuploadUrl,
secureuri:false,
fileElementId:'image',
dataType: 'json',
success: function (data, status) {
alert("Upload Complete.");
}
});
}
return [true];
}
},
这个fileElementId 指的是image。 image 只被选中一次。尝试将图像分配给images[],就像我们从纯 HTML 执行的那样。但是仍然没有运气,因为 ajaxFileUpload.js 抛出错误,因为 id not found with images[].
【问题讨论】:
-
看来你使用的是phpletter的插件。在这种情况下我需要问一下使用的是哪个版本的jQuery? ajaxFileUpload 是非常旧的插件,它不能与最新的 jquery 一起使用。您可能需要包含 migrate 插件才能使其工作。我不确定这个插件是否支持多个文件上传。只是为了测试。尝试只上传一个文件
-
单个文件上传工作正常,但不是多个。是的,插件似乎已经过时了,对支持处理多个上传的最新 jQuery 有什么建议吗?
标签: javascript jquery ajax laravel jqgrid