Advertisement
Guest User

IIS 8.5 / later upload config

a guest
Mar 21st, 2018
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.83 KB | None | 0 0
  1. protected void Button1_Click(object sender, EventArgs e)
  2. {
  3. string FilePath = FileUpload1.FileName;
  4. //verify the file whether is exist
  5. if (FileUpload1.HasFile)
  6. {
  7. //verify the file's type
  8. if (System.IO.Path.GetExtension(FilePath) != ".jpg")
  9. {
  10. Response.Write("<script>alert('The fiel type not right !')</script>");
  11. }
  12. else
  13. {
  14. FileUpload1.PostedFile.SaveAs(Server.MapPath("~/Files/NewFile.jpg"));
  15. Response.Write("<script>alert('Success !')</script>");
  16. }
  17. }
  18. else
  19. {
  20. Response.Write("<script>alert('The fiel is not exist !')</script>");
  21. }
  22. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement