Textbox.io handles uploads of local images by embedding them into the content (as a base64 data uri), then extracting them on the server on PostBack.
When each image is extracted, its binary data is passed to the ImageSave event handler. You can implement this event handler to write the image to disk, database or other storage.
The signature of the ImageSave event handler is as follows:
TextboxioControl.ImageSaveAction Editor1_ImageSave(string imageType, byte imageBytes);
Your event handler must return one of the three TextboxioControl.ImageSaveAction values:
This indicates that you have successfully saved the image, and that Textbox.io for ASP.NET should replace the embedded image with the new image URL.
This indicates to Textbox.io that it should keep the embedded image in the content. You may wish to return this value if image save failed.
This indicates to Textbox.io that it should remove the embedded image from the content. You may wish to return this value if image save failed.
If any errors occur while extracting the local images, the ImageSaveError event handler is called. You may wish to implement this event handler to display an error in your application.
The signature for this handler is as follows:
void Editor1_ImageSaveError(IList<TextboxioControl.ImageProcessingError> errors);
ImageProcessingError has 3 fields (all read-only):
|Content||string||The HTML content from the editor, before image extraction.|
Content specific to the error type:
For UnableToParseHtmlDocument: Empty string.
For InvalidBase64Data: The "src" attribute of the image
|UnableToParseHtmlDocument or InvalidBase64Data|
This example is from the ImageUpload.aspx.cs file in the demo project in the Textbox.io for ASP.NET distribution.
Can I upload using a normal HTTP upload handler?
No. This is not supported by Textbox.io for ASP.NET.
The main reason is that, with the asynchronous image uploads, an integrator must wait for image uploads to finish when posting a form. It is difficult to integrate this with the form submission in the ASP.NET framework.