Click here to Skip to main content
15,916,412 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have created a small crud application, where user can put names,addresses and other details but I do want to put an option to use image along with details,so that user can update their photo along with other details,so I want to know how to use an image there.
Posted
Comments
[no name] 4-Jun-14 14:58pm    
The same way as everyone else does. What have you tried? Have you done any research at all? What was the problem with what you have tried?
meshinator 4-Jun-14 15:02pm    
That's what i wanna know,how other did??? I cudnt get any idea ..how to start with this image thing, yeah i did ,but cudnt find anything over the internet .
[no name] 4-Jun-14 15:04pm    
You must be joking. There are thousands of examples of how to save and get an image from a database out there on the internet.
meshinator 4-Jun-14 15:14pm    
found some examples but being newbie in mvc,kind of confuse in know how to fit codes for image update,delete along with other details.
[no name] 4-Jun-14 15:25pm    
Okay... and? You expect people to write your code for you? Especially based on the zero amount of relevant information that you have given us to work with? Show us what you have tried and describe an actual problem. "I am confused" does not tell us anything about your actual problem.

Hi Umeshinator,

There are two ways you can achieve using image in MVC like
i) Store the image in some location at your sever and save its path for the user details data in a varchar column.

Ex :- Put a image upload component to your page and first upload it to a location in server. Then take that location and save it to database table varchar column. While retrieving just retrieve the path and show the image from same location.

In MVC you have to use some jQuery component for image upload.

ii) Save the whole image into database as a binary data using datatype 'Image'.


If you are already doing some CRUD operation it will be definitely easy for you to just store the image on server location and save the path to your database table.


Hope this will work as a hint for you and there is already some posts which might be of help for you. The below references show example for asp.net to store image in both way. Please refer and you can get some idea.

Reference :-
http://www.aspsnippets.com/Articles/Retrieve-images-using-a-file-path-stored-in-database-in-ASPNet.aspx[^]

Storing and Retrieving Images from SQL Server Using Strored Procedures and C#.net[^]

Post for MVC : http://stackoverflow.com/questions/16414074/mvc4-c-sharp-want-to-save-a-image-to-a-folder-and-saving-the-url-in-database[^]
 
Share this answer
 
1. Save the image in a location in server and store the path with image name in database column.
2.save the image in database.
 
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