Advertisement
Guest User

Untitled

a guest
Dec 7th, 2016
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.66 KB | None | 0 0
  1. [WebMethod]
  2. public void SaveImage()
  3. {
  4. try
  5. {
  6. if (!System.IO.Directory.Exists(HttpContext.Current.Server.MapPath("~/Upload")))
  7. {
  8. System.IO.Directory.CreateDirectory(HttpContext.Current.Server.MapPath("~/Upload/"));
  9. }
  10.  
  11. string path = HttpContext.Current.Server.MapPath("~/Upload/").ToString();
  12. var Request = HttpContext.Current.Request;
  13. if (Request.Files.Count > 0)
  14. {
  15. var file = Request.Files[0];
  16. file.SaveAs(path + file.FileName);
  17. }
  18. }
  19.  
  20. catch(Exception ex){
  21. throw ex;
  22. }
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement