开发者

getting file path through browse button

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 hi开发者_JAVA百科nt is very much appreciated.


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.


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>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜