AjaxFileUploader上传插件 兼容性好 Ie Chrome Firefoxhtml:
服务端:
using System.Web;using System.IO;namespace AjaxFileUploader.ajax{ ////// AjaxFileUploader 的摘要说明 /// public class AjaxFileUploader : IHttpHandler { public void ProcessRequest(HttpContext context) { if (context.Request.Files.Count > 0) { string path = context.Server.MapPath("~/Temp"); if (!Directory.Exists(path)) Directory.CreateDirectory(path); var file = context.Request.Files[0]; string fileName; if (HttpContext.Current.Request.Browser.Browser.ToUpper() == "IE") { string[] files = file.FileName.Split(new char[] { '\\' }); fileName = files[files.Length - 1]; } else { fileName = file.FileName; } string msg = ""; string strFileName = fileName; if (string.IsNullOrEmpty(strFileName)) { msg = "{"; msg += string.Format("error:'{0}',\n", "请选择文件!"); msg += string.Format("msg:'{0}'\n", string.Empty); msg += "}"; } else { fileName = Path.Combine(path, fileName); file.SaveAs(fileName); msg = "{"; msg += string.Format("error:'{0}',\n", string.Empty); msg += string.Format("msg:'{0}'\n", strFileName); msg += "}"; } context.Response.Write(msg); } } public bool IsReusable { get { return true; } } }}
插件:
//ajaxfileupload.jsjQuery.extend({ createUploadIframe: function (id, uri) { //创建 frame var frameId = 'jUploadFrame' + id; var iframeHtml = '