如何存储网站的根目录以外的图像 [英] How to store image outside of the website's root directory

查看:171
本文介绍了如何存储网站的根目录以外的图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想通过用户上传的所有图像保存我的网站目录以外。

让我解释一下你们

假设我有部署在服务器和目录路径的网址是:

Suppose i have a website deployed in a server and directory path is:

例如。 D:\\ TestWeb \\

在这里我目前已经添加到存储图像其他一些目录:

here currently some other directory i have added to store images as:

 D:\TestWeb\imgProfile

 D:\TestWeb\imgLocation

 D:\TestWeb\Scan

,但我不希望存储这些我的根目录D内:\\ TestWeb \\
我想这些存储到其他位置

 E:\img\imgProfile

 E:\img\imgLocation

 E:\img\Scan

在这里我不能够访问此 E:\\ IMG \\ imgProfile 使用http

请提出任何逻辑。

推荐答案

设置路径在web.config文件

Set the path in the web.config file

<appSettings>
     <add key="DocumentationLocation" value="E:\img\imgProfile" />
</appSettings>

在code:

string savePath = ConfigurationSettings.AppSettings["DocumentationLocation"];

string filename = Path.GetFileName(FileUploadControl.FileName);
FileUploadControl.SaveAs(savePath + filename);

这篇关于如何存储网站的根目录以外的图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆