Krajee文件输入小部件的“上载"方法引发异常 [英] Krajee file-input widget 'upload' method throws exception
问题描述
我正在使用krajee的fileinput小部件形式: http://plugins.krajee.com/file-input
I am using fileinput widget form krajee: http://plugins.krajee.com/file-input
使用上传"方法时我在做什么错? 当我按上传"按钮上传文件时,一切正常.但是,当尝试使用这样的上传方法时:
What I am doing wrong using 'upload' method ? When I upload files by pressing upload button everything works great. But when try to use upload method like this:
$( '#projectFiles' ).fileinput( 'upload' );
我得到一个错误:
Uncaught TypeError: Cannot read property 'undefined' of undefined
第989行.
我检查了这一行:
formdata.append(self.uploadFileAttr, files[i]);
文件在那里未定义.
那么我在做什么错了? 我的代码:
So what am I doing wrong? My code:
[js]
$( "#projectFiles" ).fileinput( {
browseClass: 'btn btn-default',
showPreview: true,
showUpload: true,
multiple: "multiple",
uploadAsync: true,
uploadUrl: "/home/UploadFiles"
} );
function submitForm( e ) {
$( '#projectFiles' ).fileinput( 'upload' );
// atach to event 'filebatchuploadsuccess' then submit rest of form
}
[ASP MVC视图]
[ASP MVC view]
@using( Html.BeginForm( "RequestPost", "Home", FormMethod.Post, new { id = "frmRequest", @class = "", enctype = "multipart/form-data" } ) )
{
<div id="projectFilesDiv" class="row">
<div class="col-xs-12 col-sm-12 col-md-12 col-lg-12">
<div class="form-group">
<input id="projectFiles" name="projectFiles" type="file"/>
</div>
</div>
</div>
@* THE REST OF THE FORM *@
<button type="button" onclick="submitForm()">SUBMIT</button>
}
预先感谢
推荐答案
答案是我使用的控件版本较旧(4.1.6),而我使用红色的文档版本较新(4.1.7). 在4.1.6中, 上载 方法必须具有参数,而在4.1.7中则没有 在4.1.6中,解决方案可以使用没有参数的 uploadBatch (我最终做了什么)
The answer is that I have older version of control (4.1.6) and documentation I have red is newer (4.1.7). In 4.1.6 upload method must have parameters, in 4.1.7 not In 4.1.6 the solution might be use uploadBatch which has no parameters (what I finally did)
这篇关于Krajee文件输入小部件的“上载"方法引发异常的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!