我想上传文件。我正在使用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()
始终为空。为什么会这样?