Where do my images go when i use FileUpload1.SaveAs(Server.MapPath())?

609 views Asked by At

Originally I started having the images put into a database and using generic handler to view the images, it was ok for one part of my app but then I realized that storing images in the database wasn't going to work out to well for a part of my application because I will be dynamically creating an html table with hyperlinks and using images for hyperlinks. So using generic handlers would see to be a huge mess when creating the html and navigation hyperlinks, So what I have opted to do is now is put these images to a folder on the server, but right now I am using my laptop before I even get to the point of publishing the app on line.

So this is the code I am using...

string iconName = fpIcon.FileName;
string iconExtension = Path.GetExtension(iconName);
string iconMimeType = fpIcon.PostedFile.ContentType;

string[] matchExtension = { ".jpg", ".png", ".gif" };
string[] matchMimeType = { "image/jpeg", "image/png", "image/gif" };

        if (fpIcon.HasFile)
        {
            if (matchExtension.Contains(iconExtension) && matchMimeType.Contains(iconMimeType))
            {
                fpIcon.SaveAs(Server.MapPath(@"~/Images/" + iconName));
                Image1.ImageUrl = @"~/Images/" + iconName;

            }
        }

So my question is, and don't laugh to hard but, where are these images being stored? I can't find them anywhere on my laptop using the windows search. With all the images that I have in this ~/Images directory, I can change the image to any image I wanted by supplying the name, but I have no idea where the images are being held, and when I do deploy to a site then where are they going to be then?

Thanks

1

There are 1 answers

1
realnero On BEST ANSWER

Server.MapPath gives your current website directory(IIS hosted or running from VS). So go to your website directory, find Images directory there and you'll see your images.