protected void Page_Load(object sender, EventArgs e) { VerifyPage("", false); try { if (!string.IsNullOrEmpty(Request.Form["id"])) { var id = HttpUtility.HtmlDecode(Request.Form["id"]); MvcUploader uploader = new MvcUploader(Context); Guid guid = new Guid(id); MvcUploadFile file = uploader.GetUploadedFile(guid); string datatime = DateTime.Now.ToString("yyyyMMddHHmmssffff"); //string ePath = System.Configuration.ConfigurationManager.AppSettings["EmailTmpDir"]; //if (!Directory.Exists(ePath)) //判断是否存在 //{ // Directory.CreateDirectory(ePath);//创建新路径 //} var fname = ""; if (file.FileName.LastIndexOf('.') != -1) { fname = file.FileName.Substring(file.FileName.LastIndexOf('.')); } file.MoveTo(Server.MapPath("/UpLoad/") + guid + file.FileName); Response.Write("{\"err\":0,\"msg\":\"Finish" + guid + file.FileName + "\"}"); Response.End(); } else { Response.Write("{\"err\":1,\"msg\":\"出错了,请重试\"}"); Response.End(); } } catch (System.Threading.ThreadAbortException ex) { } catch (Exception ee) { var hastable = new Hashtable(); hastable.Add("err", 1); hastable.Add("msg", ee.Message); var res = json.Serialize(hastable); Response.Write(res); Response.End(); } }
protected void Page_Load(object sender, EventArgs e) { VerifyPage("", false); try { if (!string.IsNullOrEmpty(Request.Form["id"])) { var id = HttpUtility.HtmlDecode(Request.Form["id"]); MvcUploader uploader = new MvcUploader(Context); Guid guid = new Guid(id); MvcUploadFile file = uploader.GetUploadedFile(guid); string datatime = DateTime.Now.ToString("yyyyMMddHHmmssffff"); if (file.FileName.LastIndexOf('.') != -1) { var extension = file.FileName.Substring(file.FileName.LastIndexOf('.')); if (".csv" == extension.ToLower()) { var path = Server.MapPath("/TempFile/Excel/") + datatime + ".csv"; file.MoveTo(path); var res = import_Click(path); if (res) { Response.Write("{\"err\":0,\"msg\":\"Finish" + guid + file.FileName + "\"}"); Response.End(); } else { Response.Write("{\"err\":1,\"msg\":\"出错了,请重试\"}"); Response.End(); } } else { Response.Write("{\"err\":1,\"msg\":\"格式错误\"}"); Response.End(); } } else { Response.Write("{\"err\":1,\"msg\":\"格式错误\"}"); Response.End(); } } else { Response.Write("{\"err\":1,\"msg\":\"出错了,请重试\"}"); Response.End(); } } catch (System.Threading.ThreadAbortException ex) { } catch (Exception ee) { var hastable = new Hashtable(); hastable.Add("err", 1); hastable.Add("msg", ee.Message); var res = json.Serialize(hastable); Response.Write(res); Response.End(); } }