Skip to content Skip to sidebar Skip to footer

Get The File Name After Click Open Button In File Browse Dialog Box Using Javascript/jquery

Basically I am new in web development and I'm facing a problem related to open file dialog box using JavaScript or jQuery my problem is that how can I open a file browser dialog bo

Solution 1:

<form><inputtype="file"></form><script>
  $(":file").change(function(){
    alert($(":file").val());
  });
</script>

put it on jsfiddle for you here: http://jsfiddle.net/9ytkn/

Solution 2:

Just get the value of the <input type="file" />.

Solution 3:

I think this is right...Should produce a "Browse" button:

<inputid="file_field"type="file"></input><buttontype="button"onclick="DisplayFilePath();">Display file path</button><script>functionDisplayFilePath(){
    alert($("#file_field").val())
}
</script>

Solution 4:

try this:

<SCRIPT>functionreverseData(val)       {var d="";var temp="";for (var x=val.length;x>0;x--) {d+=val.substring(x,eval(x-1));}return d;}
    functiongetFilename(val)       {val=escape(val);var reversedsrc=reverseData(val);var nameEnd=reversedsrc.indexOf('C5%');var name=reversedsrc.substring(0,nameEnd);name=reverseData(name);name=unescape(name);return name;}
    var daname='val';
    document.write('<INPUT TYPE="file" ID="val"><INPUT TYPE="button" VALUE="Get File Name" ONCLICK="alert(getFilename(window.document.getElementById(daname).value))">');
</SCRIPT>

put it into html file and test

Post a Comment for "Get The File Name After Click Open Button In File Browse Dialog Box Using Javascript/jquery"