Open rohan-deshpande opened 8 years ago
Just to make sure I understand the question correctly. You want to be able to access the FileReader object from your JS script?
I guess I'm just wondering how the images should get passed from the client to the server, I've got the wysiwyg inside of a form, do the images get attached to a FormData
object or something else?
Edit Okay so I see that when I call $('#editor').cleanHtml();
The images are placed into the HTML as base 64 encoded PNGs which is what the FileReader
API does for me, then whenever the HTML is displayed again, the browser will just render the image right? So I guess uploading isn't necessary in this case?
I haven't looked over that function in a while but from what I remember that is correct.
Okay yeah that seems right. Although I may want to strip those images out and store them separately somewhere, I'm using a MySQL db and if a user puts a bunch of images in the editor then the column in the db is going to get pretty insane...I can do that on the server I guess but would be nice if there was some way to access those images as an array or something on the client and then send them across neatly.
What server side language are you using?
@rohan-deshpande You can access the "uploaded" files from inside the insertFiles(files) function. This is what I did in order to force resizing of images on the fly.
Each of the uploaded files are available as the files
variable. I believe you will have to convert them to actual Images first if you wish to do image processing on them. I did this and then used Canvas
functions to resize the images.
Surely there is a more elegant solution than just directly editing that function directly, but I'm not that familiar with javascript and jQuery.
Not really an issue I guess, but what would be the recommended way to send the images placed in the editor via the
FileReader API
to the server? Is there some way to expose theFileReader
object that's used bybootstrap-wysiwyg
?