e-o*_*-on 1 c# asp.net-mvc kendo-ui kendo-upload
在Kendo上传时遇到一些问题.当文件小于15MB的最大大小时,那很好.但是,如果它超过最大大小,则不会进入"上载"操作,但仍会返回"完成"消息.
@(Html.Kendo().Upload()
.Name("files")
.ShowFileList(false)
.Async(a => a.Save("Upload", "Document", new {@id = Model.ChangeRequestId})
.AutoUpload(true))
.Events(e => e
.Complete("refreshFileList"))
)
Run Code Online (Sandbox Code Playgroud)
如果它进入操作,那么我将能够检查文件大小并返回适当的消息.如果文件太大,有没有人设法成功处理Kendo上传的情况?
谢谢
为什么不在客户端进行文件大小验证呢?
upload如果需要,使用该事件检查大小并显示消息/中止下载.
.Events(e => e.Upload("onUpload"))
Run Code Online (Sandbox Code Playgroud)
function onUpload(e) {
var files = e.files;
$.each(files, function () {
if (this.size > 15*1024*1024) {
alert(this.name + " is too big!");
e.preventDefault(); // This cancels the upload for the file
}
});
}
Run Code Online (Sandbox Code Playgroud)