jQuery结合C#上传文件的代码
来源:互联网 发布:诺基亚塞班软件下载 编辑:程序博客网 时间:2024/06/09 23:50
<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', /*设置post提交到的页面*/ type: "post", /*设置表单以post方法提交*/ dataType: "text" /*设置返回值类型为文本*/ }); } </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; } }}
阅读全文
0 0
- jQuery结合C#上传文件的代码
- 文件上传(C#代码)
- 文件上传(C#代码)
- JQuery上传控件uploadify结合Struts2多文件上传
- jquery异步上传文件代码
- C# 完整上传文件 代码
- jquery.uploadify插件与java web的结合实现多文件上传+进度条
- Struts2+Jquery.uploadify实现的文件上传特效示例代码
- jquery里uploadify的样例代码 文件上传
- coding结合xcode上传代码的步骤
- 文件上传插件jQuery-File-Upload结合CI框架案例
- Jquery ajaxfileupload.js结合.ashx文件实现无刷新上传
- springmvc结合jquery.form.js异步提交表单上传文件
- C# 结合html5 批量上传文件和图片预览
- C# 结合html5 批量上传文件和图片预览
- Jquery多文件上传前后台代码
- //C#上传图片的代码
- c#上传图片的代码
- 数论day1 —— 基础知识(们)
- oracle学习
- java编译的小把戏
- C#的相等性(值类型和引用类型)
- ajax 文件下載
- jQuery结合C#上传文件的代码
- LeetCode 答案(Easy)(201-300)
- Hadoop运行中NameNode闪退和运行mapreducer时卡在Running job.....
- 2017HDU多校第8场
- 路由最长匹配原则
- 哈佛凌晨4点半【收藏】
- VC++如何加载动态库
- 洛谷Oj-麦森数-高精度快速幂
- LeetCode 657. Judge Route Circle(C++版)