admin管理员组文章数量:1326123
get selected file path from JavaScript. Hi! I want to get selected file path from JavaScript
<input type="file" class="input-file" id="inputfile" onchange="ReadFile()">
here I want to assign file path to model.
function GetFileProerties() {
var fileproperties = {
"FileName": upload.files[0].name,
"FilePath": ** here i want to assign selected file path ** ,
"FileType": upload.files[0].name.substr((upload.files[0].name.lastIndexOf('.') + 1)),
"FileSize": upload.files[0].size,
"Modified Date": upload.files[0].lastModifiedDate
}
return JSON.stringify(fileproperties);
}
get selected file path from JavaScript. Hi! I want to get selected file path from JavaScript
<input type="file" class="input-file" id="inputfile" onchange="ReadFile()">
here I want to assign file path to model.
function GetFileProerties() {
var fileproperties = {
"FileName": upload.files[0].name,
"FilePath": ** here i want to assign selected file path ** ,
"FileType": upload.files[0].name.substr((upload.files[0].name.lastIndexOf('.') + 1)),
"FileSize": upload.files[0].size,
"Modified Date": upload.files[0].lastModifiedDate
}
return JSON.stringify(fileproperties);
}
Share
Improve this question
edited Jun 8, 2018 at 5:44
Hoppeduppeanut
1,1697 gold badges24 silver badges60 bronze badges
asked Jun 8, 2018 at 5:06
MathanKumarMathanKumar
1121 gold badge1 silver badge11 bronze badges
4
- You have "FileType" twice. I think the full path is not available for security reasons. – PepitoSh Commented Jun 8, 2018 at 5:09
-
What do you mean by the
FilePath
? You mean the path on the local PC? If so, why do you want that? – mjwills Commented Jun 8, 2018 at 5:10 - I am selecting file from my local drive so i want selected file path – MathanKumar Commented Jun 8, 2018 at 5:14
- Possible duplicate of <input type=‘file’> for IE gives full path, need file name only – mjwills Commented Jun 8, 2018 at 5:15
2 Answers
Reset to default 3This is not possible in JavaScript due to browser security considerations.
See also: How to get full path of selected file on change of <input type=‘file’>
using javascript, jquery-ajax?
Like you, I used <input type="file"...>
to allow user to select file they want me to pull data from, and now need to connect with that file to pull the data. My next attempt is bining event listener and loop to grab the file, path after it is selected.
本文标签: how to get selected file path in javascriptStack Overflow
版权声明:本文标题:how to get selected file path in javascript - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742191577a2430314.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论