fileupload没有文件:MVC 5

时间:2015-10-19 08:32:06

标签: javascript jquery file-upload asp.net-mvc-5 razorengine

我想上传文件。我正在使用ASP.NET MVC5。

这是我的观点:

 <div class="row">
    @using (Html.BeginForm("FileUpload", "CYGNET_WYC_EHR", FormMethod.Post, new { enctype = "multipart/form-data" }))
    {
         <input type="file" id="fileToUpload" name="file" />
         <span class="field-validation-error" id="spanfile"></span>
         <input type="submit" id="btnSubmit" value="Upload" />
    }
  </div>

这是我的javascript:

    $('#btnSubmit').click(function (e) {        
        debugger
        if ($('#fileToUpload').val() == "") {
            $("#spanfile").html("Please upload file");
            return false;
        }
        else {
            return checkfile();
        }
    });

此处,$('#fileToUpload').val()始终为空。为什么会这样?

0 个答案:

没有答案