中文字幕在线观看,亚洲а∨天堂久久精品9966,亚洲成a人片在线观看你懂的,亚洲av成人片无码网站,亚洲国产精品无码久久久五月天

jQuery結(jié)合C#上傳文件的代碼

2018-07-20    來源:open-open

容器云強勢上線!快速搭建集群,上萬Linux鏡像隨意使用
jQuery結(jié)合C#上傳文件的代碼
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
  <script src="jquery-1.7.1.min.js"></script>
  <script src="jquery.form.js"></script>
  <script type="text/javascript">
  function upload() {
  $("#form1").ajaxSubmit({
  success: function (str) {
  alert(str);
  },
  error: function (error) { alert(error); },
  url: 'handler1.ashx', /*設(shè)置post提交到的頁面*/
  type: "post", /*設(shè)置表單以post方法提交*/
  dataType: "text" /*設(shè)置返回值類型為文本*/
  });
  }
  </script>
</head>
<body>
  <form id="form1" runat="server" enctype="multipart/form-data">
  <input type="file" id="file" name="file" />
  <asp:Button ID="Button1" runat="server" Text="上傳" OnClientClick="upload();return false;" />
  </form>
</body>
  
handler1.ashx
  
<%@ WebHandler Language="C#" Class="handler1" %>
  
using System;
using System.Web;
  
public class handler1 : IHttpHandler {
     
  public void ProcessRequest (HttpContext context) {
  context.Response.ContentType = "text/plain";
  HttpPostedFile file = context.Request.Files[0];
  String fileName = System.IO.Path.GetFileName(file.FileName);
  file.SaveAs(context.Server.MapPath("~/") + fileName);
  context.Response.Write("OK");
  }
   
  public bool IsReusable {
  get {
  return false;
  }
  }
}
  

標簽: 代碼

版權(quán)申明:本站文章部分自網(wǎng)絡(luò),如有侵權(quán),請聯(lián)系:west999com@outlook.com
特別注意:本站所有轉(zhuǎn)載文章言論不代表本站觀點!
本站所提供的圖片等素材,版權(quán)歸原作者所有,如需使用,請與原作者聯(lián)系。

上一篇:C# 生成簡單驗證碼的代碼

下一篇:php生成縮略圖的三種模式