1

Having a few issues with Kendo Upload. When the file is less than the max size which is 15MB, then it's fine. However, if it is more than the max size, it doesn't go into the Upload action, but it still returns the message "Done".

 @(Html.Kendo().Upload()
    .Name("files")
    .ShowFileList(false)
    .Async(a => a.Save("Upload", "Document", new {@id = Model.ChangeRequestId})
        .AutoUpload(true))
    .Events(e => e
        .Complete("refreshFileList"))
    )

If it went into the action, then I'd be able to check for file size and return an appropriate message. Has anyone managed to successfully handle what happens with Kendo Upload if the file is too big?

Thanks

4

1 回答 1

8

为什么不在客户端进行文件大小验证呢?

如果需要,使用upload事件检查大小并显示消息/中止下载。

.Events(e => e.Upload("onUpload"))
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
    }
  });
}
于 2014-10-21T15:00:07.143 回答