'how to upload Image in Blazor server app and save the image in the folder (& in the server) save that url to the db
Ive to upload image along with the item and save this images in the local folder and the server image repository and the image url should be passed to db. (Have to combine the filepath and the physicalpath ) The code below is not working.
@code{
.
.
.
.
foreach (var file in args.Files)
{
var size = file.FileInfo.Size;
path = "wwwroot\images\" + file.FileInfo.Name;
FileStream filestream = new FileStream(path, FileMode.Create, FileAccess.Write);
file.Stream.WriteTo(filestream);
filestream.Close();
file.Stream.Close();
var pathUrl = path;
}.
.
.
.
arg.Data.ItemImage = path;
}
Solution 1:[1]
Hy, I used this dev express control for achieving this :
https://docs.devexpress.com/Blazor/DevExpress.Blazor.DxUpload
It needs some tuning butt in case you follow the examples it works great. Also make sure you have write premission in the folder your willing to save the files.
Give it a try, and let me know in case you got stuck.
Best regards,
Mathias
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Mathias Z |
