0

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.

Community
  • 1
  • 1
David542
  • 104,438
  • 178
  • 489
  • 842

1 Answers1

1

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.

Ryan Allred
  • 389
  • 3
  • 13