I want to do two things in my browser:
- Load a text file into a textarea (has to be choosen via dialog box)
- Save the content of a textarea into a text file (has to be choosen via dialog box again)
- Load a video file and grab the file path to use it with a video player (1)
I’ve been looking around for a while on the internet. There are some solutions for IE only via ActiveXObjects, which I can’t use (IE, seriously?). HTML5 file API has limited usability because I can’t access the selected file’s path.
I also found save dialogs for textareas, but they ignored line breaks for some strange reason and I don’t know how to fix that, if possible at all.
So here are my requirements and options:
- Support for FF and Chrome
- JavaScript, HTML5 (and PHP, if it has to be)
- possibly Silverlight, but I’m not very familiar with it and may only copy and paste :-/
- it has to work on Mac as well
The File API is HTML that would allow you to access data, after which you can manipulate binary blobs in JavaScript, but as written this is not possible in pure JS and HTML based on your requirements.
The big blocker is “saving to a text file.” The only way I’ve been able to do this is by opening up an iFrame that calls a server side language (such as PHP) to set the content type in the header to a type that prompts a download.
Flash and Silverlight are “client” technologies that run outside of the sandbox, which sounds like your only option at this point.