当使用剑道UI上传文件时,httppostdfile保持为空.它在使用选择按钮时工作正常,但在使用拖动按钮时不起作用

HttpPostedFile stays null when Kendo UI upload file is used. It works fine when using the select button but does not work when drag is used

本文关键字:按钮 选择 拖动 不起作用 工作 UI 文件 httppostdfile      更新时间:2023-09-26

我正在使用剑道UI上传。当使用选择按钮时,它工作得很好,但在HttPostedFile中使用拖动时不起作用;我的viewModel属性保持null

我已经确保属性名称和Kendo上传组件名称相同。下面是我的JavaScript代码:

$("#AvatarImageFile").kendoUpload({
            async: {
                autoUpload: true,
                saveUrl: "URL for temp"
            },
            multiple: false,
            showFileList: false,
            select: function (e) {
                var fileReader = new FileReader();
                fileReader.onload = function (event) {
                    var imagePath = event.target.result;
                    $("#uploadedAvatarImage").attr('src', imagePath);
                    $(".k-upload .k-upload-status-total").hide();
                }
                fileReader.readAsDataURL(e.files[0].rawFile);
                console.log(e.files[0]);
            }
        });.

我使用enctype = "multipart/form-data"作为标题的一部分。

好了,我知道答案了。基本上你需要将async设置为false。

async: {
            autoUpload: false,
            saveUrl:'@Url.Action("SaveImage", "User", new { userId = Model.UserID })'
        },