Click here to Skip to main content
15,893,622 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
I want to store & retrieve image from database. But I don't want to store that image in the project folder.. How to retrieve image without using image folder in project..
I don't want to use the below code.

What I have tried:

C#
string filename = FileUpload1.FileName;
           string path = Path.GetExtension(filename);
           FileUpload1.SaveAs(Server.MapPath("~/images/" + filename));

           cmd.Parameters.AddWithValue("@images", "~/images/" + filename);
Posted
Updated 16-Nov-16 1:53am
v3
Comments
Nathan Minier 16-Nov-16 7:34am    
You're asking two completely different things.

Are you trying to store an image in the database (i.e. as a VARBINARY) or are you trying to store a file path in the database(i.e. VARCHAR). Your example indicates the latter, but your question infers the former.
Developer29 16-Nov-16 7:40am    
i want to store image in database & i want to retrieve it back.
Developer29 16-Nov-16 7:43am    
Generally we will have few image in project folder that particular path will be store in database..Later we will retrieve that image..In case If the folder is not containing the image...while retrieve it wont display image. so I don't want to store in project folder.
Nathan Minier 16-Nov-16 7:57am    
Have a look at the solution presented by manu_dhobale. It looks appropriate to your situation.

1 solution

You can save images as binary data into SQL Server database, please refer Save and Retrieve images from database in ASP.Net[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900