解析Jquery的LigerUI如何?檔案上傳

來源:互聯網
上載者:User

一、在Head中加入
    <script src="../lib/js/ajaxfileupload.js" type="text/javascript"></script>
    <script src="../lib/js/ligerui.expand.js" type="text/javascript"></script>
二、Html中的Div代碼
複製代碼 代碼如下:
      <div id="AppendBill_Div" style="display:none;">    <%-- 上傳 - 單 --%>
          <table style="height:100%;width:100%">
                <tr style="height:40px">
                    <td style="width:20%">
                        表徵圖:
                    </td>
                    <td><input type="file"  style="width:200px" id="fileupload" name="fileupload"/>
                    </td>
                </tr>
          </table>
     </div>

三、Js中-寫的是關鍵區段,會LigerUI的朋友-你懂得
   1、grid中添加項【存地址欄位】
      { display: "掃描件", name: "AppendBillPath", width: 120, type: "text", align: "left" }
   2、Form可添加項【存地址和彈出選擇框】
          { name: "AppendBillPath1", type: "hidden" }, // --上傳-【5】--
          { display: "掃描件", name: "AppendBillPath", comboboxName: "AppendBillPath2", newline: true, labelWidth: 100, width: 150, space: 30, type: "select", options: {}} // --上傳-【6】--
          $.ligerui.get("AppendBillPath2").set('onBeforeOpen', f_selectAppendBillPath_1)  // 【掃描件】 // --上傳-【7】--
   3、事件
      // #region ======================================= 【上傳掃描件視窗】  // --上傳-【8】--
複製代碼 代碼如下:
      var AppendBillPathDetail = null;
      function f_selectAppendBillPath_1() {
          var imageurl = $("#AppendBill").val();
          var AppendBill_Id = $("#AppendBill").val();  // 單號
          if (imageurl.length == 0) {
              LG.showError("您沒有輸入單號,請輸入隨單號!");
              return;
          }
          if (AppendBillPathDetail) {
              AppendBillPathDetail.show();
          }
          else {
              AppendBillPathDetail = $.ligerDialog.open({
                  target: $("#AppendBill_Div"), title: '添加表徵圖',
                  width: 360, height: 170, top: 170, left: 280,  // 快顯視窗大小
                  buttons: [
                      { text: '上傳', onclick: function () { AppendBillPath_save(); } },
                      { text: '取消', onclick: function () { AppendBillPathDetail.hide(); } }
                      ]
              });
          }
      }
      function AppendBillPath_save()
      {
           var imgurl = $("#fileupload").val();
           // var filehelpcode = $("#filehelpcode").val();
          var extend = imgurl.substring(imgurl.lastIndexOf("."), imgurl.length);
          extend = extend.toLowerCase();
          if (extend == ".jpg" || extend == ".jpeg" || extend == ".png" || extend == ".gif" || extend == ".bmp")
          {
          }
          else
          {
              LG.showError("請上傳jpg,jpep,png,gif,bmp格式的圖片檔案");
              return;
          }
          var imageurl = $("#AppendBill").val();  // extend
          alert(imageurl);
          $.ajaxFileUpload({
              url: "../handle/ImageUpload.aspx?imageurl=" + imageurl, // --上傳-【9】-- aspx檔案
              secureuri: false,
              fileElementId: "fileupload", //Input file id
              dataType: "text",
              success: function (data, status)
              {
                  // ----------------- // 儲存路徑
                 // $("#AppendBillPath2").val(Data);

                  LG.tip(data);
                  f_reload();
              },
              error: function (data, status, e) {
                  LG.showError(data);
              }
          });
      }
      // #endregion

四、後台cs,寫一句關鍵的,可以返回參數,前台提示
    string url = Server.MapPath("/Image/" + gfilename + filenameext);   // 執行上傳操作

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.