I have a webpage where I need to get a filepath of a local file on the user's computer. I was thinking to have an iFrame where a user drags in the file, and the response is the filepath.
For example:
[ in ] user drags file into iFrame of webpage [ out ] webpage show the filepath of the file dropped (/Volumes/path/file)
How, exactly would I do this? (a link to a code example or tutorial would be great)
Here is the best answer I could find on SO: https://stackoverflow.com/a/7890676/651174 .
Getting the file path is a security issue. The closest you can get is the fakepath . You can also use files[0]
instead of value to get more information on the file.
Consider using HTML5 file drag-and-drop with the HTML5 FileReader API. This tutorial explains how to do it.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.