fileUploadAll.aspx.cs 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. using System;
  2. using System.Web;
  3. using System.IO;
  4. public partial class fileUploadAll : System.Web.UI.Page
  5. {
  6. protected void Page_Load(object sender, EventArgs e)
  7. {
  8. CLIP.eForm.Server.Diagnostics.LogHelper.LoggingHandler.Debug(string.Format("CLIP.eForm File Upload Start"));
  9. try
  10. {
  11. HttpPostedFile fp = Request.Files["up_path"];
  12. if (Request.QueryString != null && Request.QueryString.Count > 0)
  13. {
  14. //C:\DfhConsent\UPLOAD\201610\28\100501967.jpg
  15. string up_filenm = Request.QueryString["up_path"].ToString();
  16. CLIP.eForm.Server.Diagnostics.LogHelper.LoggingHandler.Debug(string.Format("CLIP.eForm File Upload: {0}", up_filenm));
  17. up_filenm = Server.MapPath(string.Format("./UPLOAD/{0}", up_filenm));
  18. CLIP.eForm.Server.Diagnostics.LogHelper.LoggingHandler.Debug(string.Format("CLIP.eForm File Upload: {0}", up_filenm));
  19. foreach (string f in Request.Files.AllKeys)
  20. {
  21. HttpPostedFile file = Request.Files[f];
  22. // 디렉토리 존재여부 체크
  23. DirectoryInfo di = new DirectoryInfo(up_filenm.Substring(0, up_filenm.LastIndexOf("\\") + 1));
  24. if (di.Exists == false)
  25. {
  26. di.Create();
  27. }
  28. // 파일 저장
  29. file.SaveAs(up_filenm);
  30. }
  31. }
  32. else if (fp != null)
  33. {
  34. CLIP.eForm.Server.Diagnostics.LogHelper.LoggingHandler.Debug(string.Format("Request.QueryString"));
  35. fp = Request.Files["up_path"];
  36. CLIP.eForm.Server.Diagnostics.LogHelper.LoggingHandler.Debug(string.Format("ANDROID File up_path"));
  37. CLIP.eForm.Server.Diagnostics.LogHelper.LoggingHandler.Debug(fp.FileName);
  38. string up_filenm = fp.FileName;
  39. up_filenm = Server.MapPath(string.Format("./{0}", up_filenm));
  40. CLIP.eForm.Server.Diagnostics.LogHelper.LoggingHandler.Debug(string.Format("CLIP.eForm File Upload: {0}", up_filenm));
  41. // 디렉토리 존재여부 체크
  42. DirectoryInfo di = new DirectoryInfo(up_filenm.Substring(0, up_filenm.LastIndexOf("\\") + 1));
  43. if (di.Exists == false)
  44. {
  45. di.Create();
  46. }
  47. // 파일 저장
  48. fp.SaveAs(up_filenm);
  49. }
  50. CLIP.eForm.Server.Diagnostics.LogHelper.LoggingHandler.Debug(string.Format("CLIP.eForm File Upload End"));
  51. }
  52. catch (Exception ex)
  53. {
  54. CLIP.eForm.Server.Diagnostics.LogHelper.LoggingHandler.Debug(string.Format("CLIP.eForm error: {0}", ex.Message));
  55. throw ex;
  56. }
  57. }
  58. }