How to convert upload file into base64 ? RRS feed

  • Question

  • Hi ,

    I want to upload a file and convert it into base64 before save in the database? Please tell me steps

    I used FileUpload control in my web page


    Monday, June 16, 2014 6:58 AM

All replies

  • Hi,

    Use this:

    int iLen = flupUpload.PostedFile.ContentLength;
    byte[] btArr = new byte[iLen];
    flupUpload.PostedFile.InputStream.Read(btArr, 0, iLen);
    string b64File = Convert.ToBase64String(btArr);

    where "flpupUpload" is your file upload control name.

    Admin QuikView Solution for CRM 2013

    • Proposed as answer by Anupam Bishui Monday, June 16, 2014 12:01 PM
    Monday, June 16, 2014 7:01 AM