从URL上载ASP.NET图像

use*_*982 1 asp.net file-upload image

我有一个aspx页面,用户将在其中输入有效的图像URL(例如:https://stackoverflow.com/Content/Img/stackoverflow-logo-250.png).我需要程序将此图像上传到服务器.我怎样才能做到这一点 ?

CMS*_*CMS 5

System.Net.WebClient webClient = new WebClient();

webClient.DownloadFile(@"http://stackoverflow.com/Content/Img/stackoverflow-logo-250.png",
@"c:\path\localfile.png");
Run Code Online (Sandbox Code Playgroud)

例如,您可以使用Server.MapPath获取服务器上与相对或虚拟路径对应的物理目录Server.MapPath("~/Images")