protected void Page_Load(object sender, EventArgs e) { try { string customId = Request["customid"]; if (!string.IsNullOrEmpty(customId) && Request.Files.Count > 0) { HttpPostedFile upFile = Request.Files[0]; if (upFile.InputStream.Length > 0) { string name = upFile.FileName.Substring(upFile.FileName.LastIndexOf("\\") + 1); byte[] buffer = new byte[upFile.InputStream.Length]; upFile.InputStream.Read(buffer, 0, (int)upFile.InputStream.Length); IRemotingFile ro = RemotingManager.GetManager().GetObject <IRemotingFile>(out message); flag = ro.WriteFileBytes(name, "1", customId, buffer, out message); if (flag) { string eventLog = string.Format("{0}文件名为{1}", message, name); HistoryRecordManage _hr = new HistoryRecordManage(); _hr.SaveEventLog(PPInstallHelp.CurrentUserName, PPInstallHelp.ClientIp, "定制信息管理", eventLog); } } } } catch (Exception ex) { message = ex.Message; } }
protected void Page_Load(object sender, EventArgs e) { string jSONString = string.Empty; try { string customId = Request["customid"]; string userName = Request["username"]; if (!string.IsNullOrEmpty(customId) && Request.Files.Count > 0) { HttpPostedFile upFile = Request.Files["Filedata"]; if (upFile.InputStream.Length > 0) { string name = upFile.FileName.Substring(upFile.FileName.LastIndexOf("\\") + 1); byte[] buffer = new byte[upFile.InputStream.Length]; upFile.InputStream.Read(buffer, 0, (int)upFile.InputStream.Length); IRemotingFile ro = RemotingManager.GetManager().GetObject <IRemotingFile>(out message); flag = ro.WriteFileBytes(name, Request["bagtype"], customId, buffer, out message); if (flag) { string eventLog = string.Format("{0}文件名为{1}", message, name); HistoryRecordManage _hr = new HistoryRecordManage(); _hr.SaveEventLog(userName, PPInstallHelp.ClientIp, "定制信息管理", eventLog); } } //jSONString = "{success:true,message:'上传成功'}"; message = "上传成功!"; Response.StatusCode = 200; } } catch (System.Runtime.Remoting.RemotingException ex) { Response.StatusCode = 405; message = ex.Message; } catch (System.Net.Sockets.SocketException ex) { Response.StatusCode = 405; message = ex.Message; } catch (Exception ex) { Response.StatusCode = 500; message = ex.Message; //Response.Write(ex); //Response.End(); } //Response.Write(jSONString); //Response.Flush(); //Response.End(); }