We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Blazor signature save on Server

Hello,
how can i save the png on Server path like "~\wwwroot\signatures"

Regards,
Patrik



3 Replies

YA YuvanShankar Arunagiri Syncfusion Team March 15, 2023 11:38 AM UTC

Hi Patrik,


Sorry for the delay. We have prepared the sample based on your requirement. Using the GetSignatureAsync method, we can get signature image data as string.  Using that base64 string we can save the image in wwwroot folder shown as below.


    static string path = @"..."; // give your folder in the application for storing

private async void OnSave()

    {

        string sign = await signature.GetSignatureAsync();

        var image = sign.Replace("data:image/png;base64,", "");

        string fileNameWitPath = path + DateTime.Now.ToString().Replace("/", "-").Replace(" ", "- ").Replace(":", "") + ".png";

        using (FileStream fs = new FileStream(fileNameWitPath, FileMode.Create))

        {

            using (BinaryWriter bw = new BinaryWriter(fs))

            {

                byte[] data = Convert.FromBase64String(image);

                bw.Write(data);

                bw.Close();

            }

        }

    }


Check with attached sample and get back to us if you need any further assistance on this. 


Regards,

YuvanShankar A


Attachment: SignatureSample_454890ef.zip


PC Patrik Cavallaro April 7, 2023 05:54 PM UTC

Thanks for your help, the problem soveld.!:-)




YA YuvanShankar Arunagiri Syncfusion Team April 10, 2023 04:09 AM UTC

You are welcome, Patrik. Please get back to us if you need any further assistance on this.


If that post is helpful, please consider accepting it as the solution so that other members can locate it more quickly.


Loader.
Live Chat Icon For mobile
Up arrow icon