1
我有一個aspx頁面,用戶將在其中輸入一個有效的圖像url(例如:https://stackoverflow.com/Content/Img/stackoverflow-logo-250.png)。 我需要程序將這個圖像上傳到服務器。 我該怎麼做?從URL上傳的ASP.NET圖像
我有一個aspx頁面,用戶將在其中輸入一個有效的圖像url(例如:https://stackoverflow.com/Content/Img/stackoverflow-logo-250.png)。 我需要程序將這個圖像上傳到服務器。 我該怎麼做?從URL上傳的ASP.NET圖像
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")
我可以問你爲什麼把@在URL文件名的開始? – leen3o 2009-04-21 13:53:07