Reputation: 93
I'm not sure how to go about this but I wanted to be able to load content from a file (i.e. txt, html, etc...) to my Tinymce instance.
So basically a button that initiates a file browser and then loads the content of the file to Tinymce.
I've seen this for images and image browsers but I'm not sure how to do this for files.
This would be done locally, not on a server as well.
Upvotes: 1
Views: 372
Reputation: 13744
Nick -
Prior to HTML 5, JavaScript in the browser cannot read files directly from the hard drive - this is done for security reasons:
https://en.wikipedia.org/wiki/JavaScript#Security
In HTML 5 there are new APIs that allow you to get to files. This page has a decent overview:
http://www.html5rocks.com/en/tutorials/file/dndfiles/
I would note that browser support for this is not yet universal:
http://caniuse.com/#feat=fileapi
Assuming you can use the File API you should be able to do what you want after a user selects a file.
Upvotes: 1