Take the 2-minute tour ×

In my web application, I need to be able to allow users to upload and download their images. How can this be don in ASP.net?

I want to user to be able to sign in (I already have that done) and be able to upload images to their account. Later on, I want them to be able to download them.


share|improve this question
add comment

2 Answers

up vote 1 down vote accepted

If the images are of a reasonable size, (e.g. less than a few MB), you can do this with a <input type=file> tag. Set the encoding of your form tag to multipart/form-data and implement some code-behind to get a hold of the file.

See the ASP.Net videos (Part 1) and (Part 2) for a detailed example.

Hope this helps!

share|improve this answer
add comment

You can also use

<asp:FileUpload runat="server" id="upImage" Width="575px" CssClass="txt-Normal"></asp:FileUpload>

Here is my method to save them to a location on the site.

string completeFilePath = this.Request.PhysicalApplicationPath + System.Configuration.ConfigurationManager.AppSettings["ImageUploadPath"];

if (System.IO.Directory.Exists(completeFilePath))

if (!System.IO.File.Exists(completeFilePath + this.upImage.FileName))
    this.upImage.SaveAs(completeFilePath + this.upImage.FileName);

imageUrl = string.Format("~{0}{1}", System.Configuration.ConfigurationManager.AppSettings["ImageUploadPath"], this.upImage.FileName);
share|improve this answer
add comment

Your Answer


