Friday, August 19, 2011

How to upload a external image link url and save on the disk

 We can get the use of HttpWebRequest and HttpWebResponse to send the request and get the response. Then response.GetResponseStream() will give us a stream of the image where we can use that stream to create a Image object like Image image = Image.FromStream(stream)

<%@ Page Language="C#" CodeBehind="Test.aspx.cs" Inherits="ActiveTest.Test" %>
<html xmlns="">
<head id="Head1" runat="server">
    <form id="form1" runat="server">
        <asp:TextBox runat="server" ID="txtUpload" 
            Text="" />
        <asp:Button runat="server" ID="btnUpload" OnClick="Upload" Text="Upload" />
namespace ActiveTest
    public partial class Test : Page
        protected void Upload(object sender, EventArgs e)
            HttpWebRequest request = (HttpWebRequest)WebRequest.Create(this.txtUpload.Text);
            HttpWebResponse response = request.GetResponse() as HttpWebResponse;
            Stream stream = response.GetResponseStream();         
            /// use response content type to findout the image type, 
            /// here I just use jpg to simplify the story.
            System.Drawing.Image image = System.Drawing.Image.FromStream(stream);

iPhone Launch Screen Sizes

iPhone Portrait iOS 8 Retina HT 5.5 = 1242 X 2208 Retna HD 4.7 = 750 X 1134 iPhone Landscape iOS 8 Retina HD 5.5  2208 X 1242 iPho...