I want to upload image and save in sql server as BLOB Data using .Net Web Api
Loading
I want to upload image and save in sql server as BLOB Data using .Net Web Api
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Brahma Prakash ShuklaPosted Jun 23, 2023, 6:02 AM
To upload and save an image in SQL Server as BLOB (Binary Large Object) data using ASP.NET, you can follow these steps:
Create a table in your SQL Server database to store the image data. The table should have a column of type
varbinary(MAX)to hold the binary image data. You can also include additional columns to store other relevant information about the image, such as filename, description, etc.Create an ASP.NET web form or MVC view with a file upload control to allow users to select the image file.
Handle the file upload in the server-side code (C#) of your ASP.NET application. Here's an example of how you can handle the file upload and save the image as BLOB data:
Prasad RaveendranPosted Jun 23, 2023, 3:19 AM
please review the sample code attached
Sandeep KumarPosted Jun 21, 2023, 6:08 AM
how to save image in folder path
Prasad RaveendranPosted Jun 21, 2023, 1:11 AM
Please try with below updated code.
After reading the image data as a byte array using
BinaryReader, you are adding the byte array to theDtPhotoDataTable usingDtPhoto.Rows.Add(imagecode). However, the DataTable expects a string value for the "FilePath" column, not a byte array. If you intend to store the byte array in the "FilePath" column, you should convert it to a string before adding it to the DataTable. Modifed the code as follows:Deepak RawatPosted Jun 20, 2023, 11:40 AM
Sandeep KumarPosted Jun 20, 2023, 6:30 AM
My Code is Like but not working
Rajkiran SwainPosted Jun 20, 2023, 6:10 AM