Scott Ledbetter
Scott Ledbetter

Reputation: 338

Getting local file path from html input element

I'm building an internal tool that generates a bit of applescript based on fields of a form. For the most part this is fairly straightforward, but I'm having trouble when introducing an external file.

My hope was that I could access the images file path by reading the <input type="file"> element after a user chooses a file, but I've discovered this isn't possible due to security reasons (browsers cant read local directories.

How do I solve for this? I need a way for my program to read a file path of an image the user will choose.

Upvotes: 0

Views: 3163

Answers (1)

olalahti
olalahti

Reputation: 91

How about just a regular text field, eg. <input type="text" name="filePath">, into which user drags the file from Finder? The local path of the file gets copied to the field (and to the value attribute of the field) and you can read it from there.

enter image description here

Upvotes: 1

Related Questions