Download images to server C # code based on URL
ASPX page code:
<%@ Page Language="C #"AutoEventWireup="true"codebehind="GetPictureByUrl.aspx.cs"Inherits="Hovertreemobile.getpicturebyurl" %><!DOCTYPE HTML><HTMLxmlns= "http://www.w3.org/1999/xhtml"><Headrunat= "Server"><Metahttp-equiv= "Content-type"content= "text/html; charset=utf-8"/> <Metaname= "Viewport"content= "Width=device-width, initial-scale=1" /> <title>Download images to the server according to the URL-what to ask</title></Head><Body> <formID= "Form1"runat= "Server"> <Div>image URL:<BR/><Asp:textboxrunat= "Server"ID= "Textboximgurl"Width= "$"Text= "Http://hovertree.com/hvtimg/201508/cnvkv745.jpg" /> <BR/> <Asp:buttonrunat= "Server"ID= "Btnimg"Text= "Download"OnClick= "Btnimg_click" /> <BR/><Asp:imagerunat= "Server"ID= "Hvtimg" /> <BR/> <asp:literalrunat= "Server"ID= "Ltltips" /> </Div> </form></Body></HTML>
CS Page Code:
usingSystem;namespacehovertreemobile{ Public Partial classGetPictureByUrl:System.Web.UI.Page {protected voidPage_Load (Objectsender, EventArgs e) { } protected voidBtnimg_click (Objectsender, EventArgs e) { Try{System.Net.WebClient m_hvtwebclient=NewSystem.Net.WebClient (); stringM_keleyipicture = Server.MapPath ("/hovertreeimages/keleyi.jpg"); //download files by URLm_hvtwebclient.downloadfile (Textboximgurl.text, m_keleyipicture); Hvtimg.imageurl="/hovertreeimages/keleyi.jpg"; Ltltips.text=string. Empty; } Catch(Exception ex) {Ltltips.text=Ex. ToString (); } } }}
Hovertree Open Source Project
Added image download to server function based on URL
Please see the Hovertreemobile project
Http://hovertree.com
How to ask
Source code Download Http://files.cnblogs.com/files/jihua/hovertreeCode.rar
Http://www.cnblogs.com/jihua/p/webfront.html
Download images to server C # code based on URL