简体   繁体   English

当我使用FileUpload1.SaveAs(Server.MapPath())时,我的图像在哪里?

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

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. 最初我开始将图像放入数据库并使用通用处理程序查看图像,我的应用程序的一部分没问题,但后来我意识到在数据库中存储图像并不能很好地解决问题我的应用程序因为我将动态创建一个带超链接的html表并使用图像进行超链接。 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. 因此,在创建html和导航超链接时使用通用处理程序会看起来很麻烦。所以我选择做的是将这些图像放到服务器上的文件夹中,但是现在我在使用笔记本电脑之前到了在线发布应用程序的程度。

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. 我使用Windows搜索在笔记本电脑上找不到它们。 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? 使用我在〜/ Images目录中的所有图像,我可以通过提供名称将图像更改为我想要的任何图像,但我不知道图像的保存位置,以及当我部署到网站时他们将在哪里?

Thanks 谢谢

Server.MapPath gives your current website directory(IIS hosted or running from VS). Server.MapPath提供当前的网站目录(IIS托管或从VS运行)。 So go to your website directory, find Images directory there and you'll see your images. 所以转到你的网站目录,在那里找到Images目录,你会看到你的图像。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM