Getting File Name of File Upload


/ Published in: JavaScript
Save to your folder(s)

use this script to get the name of the file that you want to upload even before uploading it


Copy this code and paste it in your HTML
  1. <script language="JavaScript"><!--
  2. function extract(what) {
  3. if (what.indexOf('/') > -1)
  4. answer = what.substring(what.lastIndexOf('/')+1,what.length);
  5. else
  6. answer = what.substring(what.lastIndexOf('\\')+1,what.length);
  7. alert(answer);
  8. }
  9. //--></script>
  10.  
  11. <form name="myform">
  12. <input type="file" name="myfile">
  13. <input type="button" value="Test" onClick="extract(this.form.myfile.value)">
  14. </form>

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.