我有一个aspx页面,用户将进入一个有效的图片网址(例如: https://stackoverflow.com/Content/Img/stackoverflow-logo-250.png )。 我需要的程序到该图像上传到服务器。 我怎样才能做到这一点 ?
Answer 1:
System.Net.WebClient webClient = new WebClient();
webClient.DownloadFile(@"http://stackoverflow.com/Content/Img/stackoverflow-logo-250.png",
@"c:\path\localfile.png");
您可以使用使用Server.Mappath获得对应的相对或虚拟路径上的服务器上的物理目录,例如Server.MapPath("~/Images")
文章来源: ASP.NET Image uploading from URL