Asp.net save web images to the server

Asp.net upload pictures function often contact, will be saved to the server from the local picture. If a web site only provides the picture, can also save the picture to the server?

 

To create a GetImage.aspx page:

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="GetImage.aspx.cs" Inherits="KeleyiTestWeb.KImage.GetImage" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Asp.net save web images to the server -KWS</title>
</head>
<body>
<form id="form1" runat="server">
<div>
To get the picture.: <asp:TextBox runat="server" ID="tbPicUrl" Text="http://keleyi.com/image/a/ipkvp9eq.jpg" Width="300" />
<asp:Button Text="Save the "runat=" server "ID=" btnSave "onclick=" btnSave_Click "/> <br /> to succeed in saving to a server at the same time will be shown in the following
<br /><asp:Literal runat="server" ID="ltlTips" />
<br /><asp:Image runat="server" ID="imgDownload" />
</div>
</form>
<div>This example please refer to: <a href="http://keleyi.com/a/bjac/4yiwpvt0.htm" target="_blank"> ;/a> </div>
</body>
</html>

Idea is to click the "save" button, according to enter the site, use the KeleyiImgDownloader class to get pictures, save to the server specified directory, and then displayed on the page. Class KeleyiImgDownloader and the integrity of the source code to download here:

 

 

Posted by Opie at December 17, 2013 - 9:13 PM