Posted By

laxman2021 on 12/14/12


Tagged

javascript image uplaod


Versions (?)

Validating Image field for Uploading Images in javascript.


 / Published in: PHP
 

URL: http://stackoverflow.com/questions/8021880/javascript-validate-filename-before-upload

javascript image uplaod

  1. <script language="javascript">
  2. function Checkfiles()
  3. {
  4. var fup = document.getElementById('filename');
  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 == "doc")
  8. {
  9. return true;
  10. }
  11. else
  12. {
  13. alert("Upload Gif or Jpg images only");
  14. fup.focus();
  15. return false;
  16. }
  17. }
  18. </script>
  19.  
  20.  
  21. <li class="two">
  22. <div class="left_nor"><input type="file" id="logo1" onchange="Checkfiles()" multiple accept='image/*' name="txtLogoFileName" tabindex="20" value="<?php if($_POST["txtLogoFileName"]) echo $_POST["txtLogoFileName"]; else echo($LogofileName); ?>" /></div> </li>

Report this snippet  

You need to login to post a comment.