Posted By

laxman2021 on 12/07/12


Tagged

image file upload


Versions (?)

Javascript : Validate file upload


 / Published in: PHP
 

URL: http://programming-tut.blogspot.in/2010/02/javascript-validate-file-upload.html

Image file upload, javascript

  1. <script language="javascript">
  2. function Checkfiles()
  3. {
  4. var fup = document.getElementById('logo1');
  5. var fileName = fup.value;
  6. var ext = fileName.substring(fileName.lastIndexOf('.') + 1);
  7. if(ext == "gif" || ext == "GIF" || ext == "JPEG" || ext == "jpeg" || ext == "jpg" || ext == "JPG" || ext == "png" || ext == "PNG")
  8. {
  9. return true;
  10. }
  11. else
  12. {
  13. alert("Upload JPG, JPEG, PNG, GIF images only");
  14. fup.focus();
  15. return false;
  16. }
  17. }
  18. </script>
  19.  
  20.  
  21. onchange="Checkfiles()"

Report this snippet  

You need to login to post a comment.