Advertisement
Guest User

Untitled

a guest
Sep 15th, 2019
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.84 KB | None | 0 0
  1. $("#uploadedfile").on("change", function()
  2. {
  3. var fileExtension = ['jpeg', 'jpg', 'png', 'bmp'];
  4.  
  5. if ($.inArray($(this).val().split('.').pop().toLowerCase(), fileExtension) == -1)
  6. {
  7. // alert("Only '.jpeg','.jpg', '.png', '.bmp' formats are allowed.");
  8. $("#file_error").html("Only '.jpeg','.jpg', '.png', '.bmp' formats are allowed.");
  9.  
  10. $("#uploadedfile").val("");
  11.  
  12. }else
  13. {
  14. $("#file_error").html("");
  15.  
  16. var file = this.files[0],
  17. fileName = file.name,
  18. fileSize = file.size;
  19.  
  20. readURL(this);
  21.  
  22. if(fileSize>10000000)
  23. {
  24. $("#file_error").html("File size is greater than 10MB");
  25. $("#uploadedfile").val("");
  26. }
  27.  
  28. }
  29.  
  30. });
  31.  
  32. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement