Download images to server C # code based on URL

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.