fileUploadAll.aspx.cs 2.4 KB

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