简体   繁体   中英

Tinymce - Loading local file content to Tinymce Instance

I'm not sure how to go about this but I wanted to be able to load content from a file (ie 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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM