从URL ASP.NET图片上传 [英] ASP.NET Image uploading from URL

查看:193
本文介绍了从URL ASP.NET图片上传的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个aspx页面,用户将进入一个有效的图片网址(例如:<一href=\"http://stackoverflow.com/Content/Img/stackoverflow-logo-250.png\">http://stackoverflow.com/Content/Img/stackoverflow-logo-250.png).
我需要的程序到该图像上传到服务器。
我怎样才能做到这一点?


解决方案

  System.Net.WebClient的WebClient =新的WebClient();webClient.DownloadFile(@http://stackoverflow.com/Content/Img/stackoverflow-logo-250.png
@C:\\路径\\ localfile.png);

您可以使用 使用Server.Mappath获得对应的相对服务器上的物理目录或虚拟路径,例如使用Server.Mappath(〜/图片)

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

解决方案

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")

这篇关于从URL ASP.NET图片上传的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆