0

JSF CODE LINK HERE

Here in this code i use <input type="file> and i want a full path after user browse any file.

HTML

<input class="file_upfile" type="file" />
<input class="btn_showpath" type="button" value="Show Full Path"/>
<p class="p_upfilepath">Full path will display here<p>

Here i use $('.classname').val(); function but return only FILENAME.txt(e.g) in FireFox and if i use this same code in IE and Chrome return "C:/fakepath/myfilename.txt"

jQuery

/* Here <p> show only file name, I want a full path of file
   like "c:\something\folder\filename.txt"   */

$('.btn_showpath').click(function(){
    var getpath = $('.file_upfile').val();
    $('.p_upfilepath').slideUp(function(){
        $('.p_upfilepath').text('"'+getpath+'"').slideDown();
    });
});

CSS

.p_upfilepath{
    background:#aaaaaa;
    padding:3px 10px;
    width:auto;
    color:#555555;
}
Sandy
  • 653
  • 1
  • 4
  • 9

1 Answers1

0

I think you cant get full path of file .

Or file is stored actually on remote users machine so its dosent matter where is a file located . Some browsers have a security feature that prevents javascript or any script from knowing your file's local full path. It makes sense - as a client, you don't want the server to know your local machine's filesystem.

Anant Dabhi
  • 9,506
  • 2
  • 28
  • 48
  • I want to make a custom input file button. I actually hide original button and shows my custom button and trigger click event of org. button when click on my dummy browse button. and want to show full path in my custom input button that's why i want to get full path of original button and then want to show in dummy one. – Sandy Jul 30 '13 at 04:44