首页 > 代码库 > Upload file
Upload file
<h3>Upload File</h3> <form action="@Url.Action("Upload","UploadController")" method="post" id="uploadForm" enctype="multipart/form-data"> <div class="file-box"> <input type="text" class="txt"/> <input type="button" value="http://www.mamicode.com/Browser" class="fileInputbtn"/> <input type="file" class="fileInput" id="uploadFile" name="uploadFile"/> <input type="button" value="http://www.mamicode.com/Upload" class="fileInputbtn" id="btnUpload"/> <input type="button" value="http://www.mamicode.com/Cancel" class="fileInputbtn" id="btnCancel"/> </div></form><script type="text/javascript"> $(document).ready(function () { $(".fileInput").change(function () { $(".txt").val($(this).val()); }); $("#btnCancel").click(function () { $(".txt").val(""); }); $("#btnUpload").click(function () { var filePath = $(".txt").val(); if (filePath.length == 0) { alert("Please upload a file."); return; } var extension = filePath.split(‘.‘).pop(); if (extension != "xlsx") { alert("Please upload a correct file(.xlsx)."); return; } $("input[type=‘button‘]").attr("disabled", "disabled"); $(".button_01").attr("disabled", "disabled"); $(".error").html("Uploading... please don‘t close the browser."); $("#uploadForm").submit(); }); });</script>
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。