This is a migrated thread and some comments may be shown as answers.

Convert files to base64 before upload

1 Answer 1347 Views
Upload
This is a migrated thread and some comments may be shown as answers.
moosh
Top achievements
Rank 1
moosh asked on 02 Sep 2019, 04:13 PM

Hello,

Because of technical restrictions, I need to encode files in base64 format before upload.

To do that, I use the upload event of the Kendo Upload Widget to make a FileReader object with an onload event on that reader to get a base64 string.

Problem: the async upload handler is called before the reader onload finish. It’s a normal behavior because the both object are async. 

How can solve that ? Is there a better method ?

Thanks a lot

moosh

1 Answer, 1 is accepted

Sort by
0
Misho
Telerik team
answered on 04 Sep 2019, 11:34 AM
Hello,

You could check the following approach for modifying the images before upload:
https://docs.telerik.com/aspnet-core/knowledge-base/upload-resize-image-before-upload
It relies on disabling the automatic upload, hooking to the select event of the widget and uploading the file once it is processed in the FileReader onload handler.

You could find a working MVC sample in the attachment for convenience.

I hope you will find this information useful.

Best Regards,
Misho
Progress Telerik
Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Tags
Upload
Asked by
moosh
Top achievements
Rank 1
Answers by
Misho
Telerik team
Share this question
or