File Upload - Save file paths in sql
I am using blazor and the syncfusion file upload component, I save the files in the file system and after that, I try to save the file path in the database. I am trying to achieve this without using API, I'm using dapper to insert the data into the database.
To be more specific I need to wait for UploaderObj.Upload() to finish completely and then to get the file paths so I can save them in the database.
Is there any event that executes after ValueChange? I tried the events: Success, OnActionComplete but they execute before the ValueChange event.
I can't use Task.Delay because the time to finish the upload and call the external method depends on the file size.
Thanks for your help :D
Hi Chris,
in my case, I'm using web assembly and using the API found in your documentation for the files(image) upload. The uploads are working perfectly, I have an edit form to collect data of an idem and upload images.
I'm using dapper and I'm able to save the items data
[Required]
public int ItemIDNumber { get; set; }
[Required]
public string ItemName { get; set; }
[Required]
public string? ItemDescription { get; set; }
the item IDNumber is created automatically by sql
but I'm trying to find a way to save the image paths of the uploaded item to sqlserver database where each image associated with the item should have the itemIDNumber to its column
[Required]
public Guid ItemImageID { get; set; }
[Required]
public int ItemIDNumber { get; set; }
[Required]
public string ItemImageUrl { get; set; }
You can get the destination file path from the valuechange event. However, due to security concerns, the file path from the client machine is restricted.
Okay understood. But how can i save images to the server project directory without the API ?
i want to upload photos to a folder "Uploads" in the Server directory but before the upload, i want to be able to create guid for each file to rename the filename and save as the guid with its extension then get the new guid file name
You can refer to the below Syncfusion forum for more information about your requirement.
https://www.syncfusion.com/forums/157285/blazor-file-upload-not-working-webassembly?reply=NtVBkQ