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

Save image to absolute server path

1 Answer 153 Views
ImageEditor
This is a migrated thread and some comments may be shown as answers.
Mehmet
Top achievements
Rank 1
Mehmet asked on 05 Jan 2021, 12:39 PM
Instead of saving file locally is it possible save image to absolute server path.

1 Answer, 1 is accepted

Sort by
0
Petar
Telerik team
answered on 08 Jan 2021, 12:06 PM

Hi Mehmet,

What you can do is to configure the component to send a request with the image data to an action on the server, where you can access that data and save it. 

Use the ImageEditor's SaveAs configuration and specify the path to the action, as well as enable ForceProxy:

.SaveAs(s => s.ProxyURL("Home/ImageSave").ForceProxy(true))

Then the code for the backend controller could be something like:

[AcceptVerbs("Post")]
public ActionResult ImageSave(string contentType, string base64, string fileName)
{
    var fileContents = Convert.FromBase64String(base64);
    // ...custom logic for saving the string to the database...

    return File(fileContents, contentType, fileName);
}

The image data is sent as a base64 encoded string to the action. You can access it through the string base64 parameter and save it based on your requirements.

Regards,
Petar
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

Tags
ImageEditor
Asked by
Mehmet
Top achievements
Rank 1
Answers by
Petar
Telerik team
Share this question
or