0

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.

2
  • You could add a listener for the "chance" event to get a list of files selected. Checkout HTML5 File API Commented Jul 9, 2018 at 19:59
  • Check it out, do you know if that can provide the element with a full file path of the user's local directory? Commented Jul 9, 2018 at 20:56

1 Answer 1

1

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

Sign up to request clarification or add additional context in comments.

4 Comments

Dude, this is perfect!! I wish I could do it via an upload button too but this is great.
Happy to help! Btw, why do you ask for the local path on a web form? User could also choose the file path during the generated AppleScript is run with choose file name command that displays a file dialog.
The apple script builds an illustrator document based on the selected parameters of the web form, so having all of the selections/choosing of an image (which will be placed as a background image) in one place is ideal to me.
@ScottLedbetter, if you're happy with this solution, you could help the author of this answer and the users of the site by selecting this answer. It's the best way to say thank you.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.