tags:

views:

66

answers:

2

i have put a browse button in my html form. with the help of it i just want to get only the file path not the file itself. for ex: if i browse to "D:\Raghu\hgg" all i want is the path itself, not the "hgg" folder. is it possible? any hint is very much appreciated.

A: 

If hgg is filename then it should be possible. Just attach change event to the input, and read input.value to get real filename (without path):

<input type="file" id="t" />
<script>
    document.getElementById("t").addEventListener("change", function() {
        alert(this.value);
    }, false);
</script>
Crozin
will it not work for folders. any approach for folders?
sushant
`input[type=file]` doesn't allow to select a folder - you have to choose a file.
Crozin
+2  A: 

All modern browsers will only give you the filename; this is due to some sort of security issue. All versions of IE will give you the complete path though (you have to change a security setting to get the complete path in IE8).

In short, I don't think you can't get the full path these days.

tau