user29982
user29982

Reputation: 443

ASP.NET Image uploading from URL

I have an aspx page,where the user will enter a valid image url(ex : https://stackoverflow.com/Content/Img/stackoverflow-logo-250.png). I need the program to upload this image to the Server. How can i do this ?

Upvotes: 1

Views: 3653

Answers (1)

Christian C. Salvadó
Christian C. Salvadó

Reputation: 827862

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

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

You can use Server.MapPath to get physical directory on the server corresponding to the relative or virtual path, for example Server.MapPath("~/Images")

Upvotes: 7

Related Questions