fileUploadAll.aspx.cs 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  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 all 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. up_filenm = Server.MapPath(string.Format(@".\UPLOAD\{0}", up_filenm));
  41. CLIP.eForm.Server.Diagnostics.LogHelper.LoggingHandler.Debug(string.Format("CLIP.eForm File Upload: {0}", up_filenm));
  42. // 디렉토리 존재여부 체크
  43. DirectoryInfo di = new DirectoryInfo(up_filenm.Substring(0, up_filenm.LastIndexOf("\\") + 1));
  44. if (di.Exists == false)
  45. {
  46. di.Create();
  47. }
  48. // 파일 저장
  49. fp.SaveAs(up_filenm);
  50. }
  51. CLIP.eForm.Server.Diagnostics.LogHelper.LoggingHandler.Debug(string.Format("CLIP.eForm File Upload End"));
  52. }
  53. catch (Exception ex)
  54. {
  55. CLIP.eForm.Server.Diagnostics.LogHelper.LoggingHandler.Debug(string.Format("CLIP.eForm error: {0}", ex.Message));
  56. throw ex;
  57. }
  58. }
  59. }