PDA

View Full Version : Multipart form upload - sending HtmlEditor content as a 'file'



CaCtus491
16 Jun 2014, 6:30 AM
I have the need to send the content of a HtmlEditor field as a multipart form request, along with some other field parameters. Basically I'm trying to emulate a multipart form that, amongst other fields, contains a file field. Rather than having the user select a HTML file from their local machine, the content of the 'file' should come from a HtmlEditor component.

Before I go and implement my own solution using a "new XMLHttpRequest()", does anyone have any suggestions as to how I could use functionality within ExtJS to simplify the process?

Gary Schlosberg
16 Jun 2014, 9:44 AM
Perhaps you can just submit the form and then have the server script write the htmleditor content to a file.

CaCtus491
16 Jun 2014, 9:31 PM
Yes, that would be a good option if possible, however it isn't.

I ended up implementing my own solution which was actually much easier than expected using the FormData object. Luckily we have the ability to dictate that a compatible browser is used.

If anyone comes across this post and is looking for a good quick reference, please see the following link:
https://developer.mozilla.org/en-US/docs/Web/Guide/Using_FormData_Objects