ajax form表單提交 input file中的檔案
阿新 • • 發佈:2019-01-28
<div id="index_Dialog" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="myCaseLableJH" aria-hidden="true"><form id="index_form" name="indexUploadJH_form" role="form" method="post" class="form-horizontal" enctype="multipart/form-data"> <b>請上傳</b> <br /> 圖片上傳:<input id="uploadifyID" name="uploadifyID" type="file" multiple="multiple"/> </form> <input class="btn btn-primary" value="提交" type="button" onclick="javascript:indexFunction();"/> </div> <script type="text/javascript"> // 認證必填框驗證 function indexFunction() { if ($("#Pass").val() == "") {//密碼不能為空 $("Pass").siblings('.CasevalidText').text('密碼不能為空').show(); return; } var Count = $("#uploadifyID").data('uploadify').queueData.queueLength; if (lawyerCertificateJHCount <= 0) { alert("請上傳檔案"); return; } $('#uploadifyID').uploadify('upload', '*'); } //清除並且關閉窗體 function clearfromCasePassdata() { // $("#index_form :input").not(":button, :submit, :reset, :hidden").val("").removeAttr("checked").remove("selected"); //核心 $("#index_Dialog").modal('hide'); } $(function () { //上傳文書附件管理 loadFun();//初始化外掛 }) //關閉上傳圖片窗體 function ClosePDFsee() { $("#index_Dialog").modal('hide'); } function loadFun(){ $('#uploadifyID').uploadify({ 'swf': '/Scripts/uploadify/uploadify.swf', //FLash檔案路徑 'buttonText': '瀏 覽', 'width': 40, // 按鈕的寬度 'height': 15, //按鈕文字 'uploader': '/Home/getCasePassInfo', //處理檔案上傳Action 'queueID': 'lawyerCasefileQueue', //佇列的ID 'queueSizeLimit': 999, //佇列最多可上傳檔案數量,預設為999 'auto': false, //選擇檔案後是否自動上傳,預設為true 'multi': false, //是否為多選,預設為true 'removeCompleted': true, //是否完成後移除序列,預設為true 'fileSizeLimit': '0MB', 'fileTypeDesc': "Image Files", //Files 標識可以上傳任意檔案 'fileTypeExts': '*.jpg;*.png;*.gif;*.jpeg;', //允許上傳的檔案型別,限制彈出檔案選擇框裡能選擇的檔案 'onQueueComplete': function (event, data) { //所有佇列完成 後事件 $('#uploadifyID').uploadify('cancel', '*'); }, 'onUploadStart': function (file) { $('#uploadifyID').uploadify("settings", 'formData', { 'Pass': $("#Pass").val(), Phone: $("#Phone").val(), no: $("#no").val(), name: $("#name").val(), fileIndex: file.index, filelength: $("#uploadifyID").data('uploadify').queueData.queueLength, intCount: file.index }); }, 'onUploadError': function (event, queueId, fileObj, errorObj) { }, 'onUploadSuccess': function (file, data, respone) { data = JSON.parse(data); if (data.id == 2) { $("#index_Dialog").modal('hide'); $('#IndexmediaForm').media({ width: 500, height: 600, src: url }); $("#newDialog").modal('show'); } else { alert("上傳失敗," + data.message); } } }); }
原文地址:https://www.cnblogs.com/Leo_wl/p/4393190.html