how to save image on server and add image url to database for display on web page

I am trying to figure out how to allow a user to insert a new record into the database with the option of adding an image to the item.  The picture would then be saved on a web server and the link to the picture would be saved in a column of the table.  I would then need to display the picture along with its other information such as a description when the user selects the record from a drop down list on the page.  I have been searching everywhere and cannot find a good guide to help me accomplish this.  Can someone please help me?

5/14/2008 5:58:53 AM 91979 articles. 4 followers. Follow

6 Replies

Similar Articles

[PageSpeed] 51


There are a bunch of starter kits on this website that you can download.  Quite a few of them have code in them that does exactly what you want to do.

Last time I looked, the Personal Starter Kit did this.

Check them out!

5/14/2008 6:14:35 AM
installed the kit but when I tried to run the website I keep getting a bunch of css errors.
5/14/2008 5:26:47 PM


Firstly, you can use FileUpload control to upload the images to server via FileUpload1.SaveAs("path on server");

And then insert the information of image uploaded to database. The information contains the image path on the server and image name, image id.

Then you can use GridView or other controls display these images all.

If there are the paths of images stored in the database, you can retrieve it into a string variable and use ImageControl1.ImageUrl=path to show the picture.

You can use DataTable to retrieve the image url from database. And create a tample field to reload the image control.

    <asp:GridView ID="GridView1" runat="server" DataKeyNames="ID"
            DataSourceID="SqlDataSource1" >
            <asp:Image ID="Image1" ImageUrl='<%# Eval("thumbnailURL") %>' runat="server" />
            <br />
    </asp:GridView >
        <asp:SqlDataSource ID="SqlDataSource1" runat="server"
            ConnectionString="<%$ ConnectionStrings:ConnectionString %>"
            SelectCommand="SELECT * FROM [photo]"></asp:SqlDataSource>

Hope it helps.


Vince Xu
Microsoft Online Community Support
Please remember to mark the replies as answers if they help and unmark them if they provide no help.
5/16/2008 2:28:55 AM

here is file upload control that can upload images, and let the user browse it too.  Scroll down the comments to see how you would add to database also.  Saves a lot of time...

5/16/2008 2:39:22 AM


Try this

 1.Insert image to server and database

     if (FileUpload1.HasFile)
            string imagepath = FileUpload1.PostedFile.FileName;
            image = Path.GetFileName(imagepath);
            FileUpload1.PostedFile.SaveAs(Server.MapPath("Images") + "\\" + image);//Insert image to server
          ( Insert image name(image) to database    )

2.Retrive  image from the server

    (path->select image name from the database)
    string image = "Images/" + path;    


'If it help you then mark it as answer'

5/16/2008 9:56:05 AM

Hi Buddy,

This can be performed by defining the attribute in the database as BLOB any way its more to explain i have not enough time.So i will give you the link

Learn->DataAccessTutorials->you wil fing topic for BLOBS

but i will give you the hint You insert the Image URL into database and when retriving refer to the URL and then access it

Mark As Answer if this helps you

Further Queries Recommended

Happy Coding


Don't Forget to Mark as Answer for the post that helped you.
5/16/2008 10:07:38 AM

Similar Artilces:

How to display an image saved in a database on the web page?
I need to read an image from the database and display it on a webpage.... any ideas?  Thanks in advance :) Hi, I hope the article will help u.. CheersPlease mark as Answer if it helps u. Thanks!Parth PatelTechsture TechnologiesSoftware DeveloperAhmedabad Hi, If you have seave the details related to the images,  then just read the details and set the path of the image to image control. Try:,A...

Save Image Path into Database, Retrieve Image Path by Particular Image ID and Display Image through Gridview
Hi All, Currently, I have a file upload control in my aspx page to allow user to upload images. When the user clicks the SAVE button, the image will be saved in a particular folder named 'PMap' that located within the website. What I am trying to do here is to direct all uploaded images into a common image folder (in this case 'PMap') and then, retrieve the images and displayed it through a Gridview according to its respective image id. I have managed to store all uploaded images into a common image folder, PMap. However, I hope advice can be given on my following pro...

Add image source URL to Spotlight Comments on OS X when saving an image from the web
Name: Joe Product: Firefox Summary: Add image source URL to Spotlight Comments on OS X when saving an image from the web Comments: Just because it would be nice to see where I've gotten some of the images I download. Browser Details: Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.6; en-US; rv: Gecko/20091102 Firefox/3.5.5 From URL: Note to readers: Hendrix gives no expectation of a response to this feedback but if you wish to provide one you must BCC (not CC) the sender for them to see it. ...

How to Insert Image Url and Display the Image of that Image Url in the Grid View?
Any one can help me out about this- How to Insert Image Url and Display the Image of that Image Url in the Grid View Hi You can add HyperLink control to Gridview by setting its ImageUrl and NavigationUrl property Please refer example. <asp:HyperLink ID="HyperLink1" ImageUrl="images/image.gif" NavigateUrl="PageUrl.aspx" runat="server">HyperLink</asp:HyperLink>Please mark the post as answered if it helped you. Hi sandynaidu, This is easy to solve. Assuming that your GridView's ID is gv, that you want to have the image in your firs...

How to Insert the Image URL into Sql database and display that particular Image of the URL in GridView
 How to Insert the Image URL into Sql database instead of storing the original image itself and display that particular Image of the URL dynamincaly in GridView.For example for each product there will be one image ,here i want to store that Image URL (locally/in other Links) into the Sqldatabase and on selecting foran particalur product id i want it to display that image of the product in Grid View.How can i proceed........?i am seeking for help.   If I understood you question this is not very hard 1.  Created a table id, description and ImgUrl.  The ImgUrl field ...

!!!!! Image on master page wont show when image url is set to a image from content page !!!!!!
 Hi guys, I have this problem which i cannot seem to understand... here goes... i have a master page and an image control on is a social networking website and then i have a content page..there is a link button on the master page when when clicked shows a modal popup which has a fileupload control and a user can submit an image file...when he does so the image get saved in a directory and also its complete address is saved in the 2 problems... after committing these actions (on the master page code file ) i set the image url to the saved path ...

Can I display an image without getting the image from a URL?
From what I've read, it appears you can take an image and create a thumbnail of it with the result being a type 'image'. However, a search of dozens of sites suggests (hopefully this isn't true) that one always uses the URL of an image file to get the image to a control--meaning I can't just use the image created from the workup of an original image. I'm posting the demo code I'm trying, hoping that maybe I'm missing one or two easy steps.    Dim FullImage As Image = Image.FromFile("C:\temp\Picture1.jpg") ...

Display image from Web folder if image from database is null?
This has probably already been posted somewhere but I'm having trouble finding it.  I am displaying images from a SQL database in a detailsview.  If that field is null I would like to display a default .jpg from my web folders.  I see that it is easy to do with an asp:ImageField and the NullImageUrl, but I am using a TemplateField with the following type of setup and the NullImageUrl is not available to me? <asp:TemplateField HeaderText="Photo (if available)"> <ItemTemplate> <img src="Handler.ashx?PhotoID=<%#Eval("ID") %&...

Displaying image from database(image datatype) to image control
Hie all...I'm a newbie at I m currently using 2.0.I m having a problem with displaying images on my web form. Have tried looking thru all codes but i can't find a step by step tutorial for doing so. I understand that in 1.1, the detailsview can automatically be linked to the image field and display the image. But this is not possible now. So, i have decided to just display the image in an image control.from my understanding, 1. retrieve image from database and convert it to temporary image file in a file path. 2. use the image control's imageurl to point to the file....

How to save image in sql server and display that image in datagrid??
Hay Friend's Can u plese send me the way how to save image in sql server and display that images in datagrid or other control also like Image control or Image control Button?? Plese send the coding in C#.  Thank's Amit try this display image in data grid... and for further reference you can refer  RegardsAmit Hi amit, thanks for ur link but I m not fully Satisfy.. so kindly Send me more solutions.. Thank's Amit Hi Amit, Thanks for ur Link,...

How do I get and save an image off of a web page
I want to grab a web page via HTTP:Request and then parse it and grab an = image off of it and save that image to the hard disk. Has anyone done = this and/or can anyone point me in the right direction? Thanks, Guy Davis This would do it... #!/usr/bin/perl use LWP::Simple; use strict; my $content=get(""); open(OUT, ">image.jpg") or die $!; binmode(OUT); print OUT $content; close(OUT); Regards, Agustin Rivera Webmaster, ----- Original Message ----- From: "Guy D...

Add images from database to web page
Hi all, I can display an image from a db on a page, but how can i sisplay this image in a table with other text? This line displays the image: im.Save(Response.OutputStream,System.Drawing.Imaging.ImageFormat.Jpeg); but it wipes out everything else on the page and only displays that image. Thanks in advance! You should a sepearate page for an image (Image.aspx) Then where ever you want to show the image use the img tag <img src="Image.aspx?query">...

Displaying a database image on a web page?
I am having trouble locating any examples of how to output an image to an html page that is originally sourced from a blob column of an sql data table. I cannot directly display the image as I have to remove the first 4 characters from the stream before the image data starts. In the past with other languages I have written this image stream out to file and passed the imageurl to the page. This worked ok but it left me with the maintenance task of cleaning these temp image directories at a later date. Is there a way I can bind a stream of bytes directly to an image control and have t...

Save Image is database or in web server
Hi Experts,          We are going to create Photo Printing & Social Networking site like,,, Everything is running fine. But Now I am facing some problems. When user Upload several(no limit) his/her Photo(s), I save those photo in Sql Server Database in Image datatype. & we are saving three sizes of every image. (one is original, second is thumbnail size & third one is larger then thumbnail and smaller then original) I have some reason to save Images in sql Server.1. In databas...

Web resources about - how to save image on server and add image url to database for display on web page -

Database - Wikipedia, the free encyclopedia
A database is an organized collection of data . The data are typically organized to model aspects of reality in a way that supports processes ...

Database - Wikipedia, the free encyclopedia
... requiring information. For example, modelling the availability of rooms in hotels in a way that supports finding a hotel with vacancies. Database ...

Dodgy database exposes details of 191 million US voters
... years, there's a high chance that your personal details are now out in the wild. Security researcher Chris Vickery found a misconfigured database ...

Huge database of 191 million U.S. voters found on the open Internet
... such bulk information online, a recent discovery seems to indicate. According to VentureBeat , a security researcher found the exposed database ...

3.3 million Hello Kitty fans' details have been exposed in a huge database leak
... week after week, the hacks, breaches and data leaks continue to roll in. The latest victim? Hello Kitty. CSO Online is reporting that a database ...

Under pressure, DNC restores Bernie Sanders campaign's access to their database - Videos - CBS News
A strange twist in the race for the democratic presidential nomination: the campaign of Vermont Senator Bernie Sanders has filed a complaint ...

Massive Voter Database Left Open For Public Consumption
Gosh, we could have avoided all the angst about the Clinton/Sanders voter database breach if only we'd known about this major database , accessible ...

Database configuration issues expose 191 million voter records
A misconfigured database has led to the disclosure of 191 million voter records. The database, discovered by researcher Chris Vickery, doesn't ...

Database error publishes data of 3 million Hello Kitty fans
Online researcher Chris Vickery uncovered a database this weekend containing the personal information of 3.3 million accounts associated with ...

191 Million US Voter Registration Records Leaked In Mystery Database
A huge database of 191 million US citizens is uncovered. But no one knows who carelessly left it open, whilst the FBI have been contacted.

Resources last updated: 1/2/2016 2:30:55 AM