Convert files to base64 before upload

2 posts, 0 answers
  1. moosh
    moosh avatar
    9 posts
    Member since:
    Aug 2019

    Posted 02 Sep 2019 Link to this post

    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

  2. Misho
    Admin
    Misho avatar
    212 posts

    Posted 04 Sep 2019 Link to this post

    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.
Back to Top