This gives a very basic file upload form to a user which allows them to upload an image.
After the image has been uploaded, the dialog closes and an image is placed into the area.
This was written for TinyMCE version 4.0b1 (2013-04-11)
It utilises the iFrame Post Form plugin, which can be found here:
http://sourceforge.net/projects/iframepostform/files/
Your TinyMCE init() method should contain the following value:
tinymce.init({
...
imageupload_url: '/my/uploader/path', // PHP (or other server side script)
// imageupload_rel: 'http://cdn.somewhere.com/media/tinymce-plugin/imageupload', // use if not installed in plugin folder.
plugins: 'imageupload', // and your other plugins
toolbar1: 'imageupload' // and your others
...
});
It handles a couple responses, which are:
{"error":false,"path":"http:\/\/www.mydomain.com\/myimage.jpg"}
An invalid image error message is produced by returning this:
{"error":"filetype"}
An unknown error message is produced with this:
{"error":"unknown"}
The jquery.iframe-post-form.js script commonly available fails to parse a JSON response in Chrome. This is mainly because chrome wraps the returned text in a 'pre' tag. Its a simple one line fix to the script, .html() is changed .text(). You can get the fixed script here - https://github.com/worldspawn/jquery.iframe-post-form