【发布时间】:2012-05-22 05:30:31
【问题描述】:
我知道如何使用 fileupload 控件和 saveas 方法将图像保存到文件夹。但是我从图像控件中获取图像并将其保存到文件中而不使用文件上传控件 n 将其保存在文件夹中。
【问题讨论】:
我知道如何使用 fileupload 控件和 saveas 方法将图像保存到文件夹。但是我从图像控件中获取图像并将其保存到文件中而不使用文件上传控件 n 将其保存在文件夹中。
【问题讨论】:
string filepath = img1.ImageUrl;
using (WebClient client = new WebClient())
{
client.DownloadFile(filepath,Server.MapPath("~/Image/apple.jpg"));
}
【讨论】:
你知道图片路径吗?您可以从图像控件中获取图像路径,然后在代码中下载图像:
Download image from the site in .NET/C#
using(WebClient client = new WebClient())
{
client.DownloadFile("http://www.example.com/image.jpg", localFilename);
}
【讨论】:
首先获取图片的Url,然后使用webclient可以将文件保存到文件夹中
string filepath = img1.ImageUrl;
using (WebClient client = new WebClient())
{
client.DownloadFile(filepath,Server.MapPath("~/Image/apple.jpg"));
}
这将使用 ImageName apple 将图像保存在图像文件夹中...
【讨论】: