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.
Asked
Active
Viewed 5,288 times
2 Answers
3
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
- 6,499
- 10
- 37
- 60
-1
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
- 43,890
- 13
- 88
- 135
-
`input[type=file]` doesn't allow to select a folder - you have to choose a file. – Crozin May 10 '10 at 12:01