【问题标题】:ASP.NET Image uploading from URL从 URL 上传 ASP.NET 图像
【发布时间】:2010-09-20 08:51:30
【问题描述】:

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

【问题讨论】:

    标签: asp.net image file-upload


    【解决方案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")

    【讨论】:

    • 我能问一下为什么你把@放在URL和文件名的开头吗?
    • @leen30 用于转义 \ 字符
    猜你喜欢
    • 1970-01-01
    • 2017-01-28
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-03-22
    • 2010-11-17
    • 2018-08-20
    • 2019-02-18
    相关资源
    最近更新 更多