Image from URL

Last post 01-17-2007 9:04 PM by Jigar. 7 replies.

Sort Posts:

  • Image from URL

    01-14-2007, 9:28 PM
    • Loading...
    • miztiik
    • Joined on 10-22-2006, 1:19 AM
    • Hell
    • Posts 236

    i want to create a image[asp.net application] with another image as a canvas.

    Now what i would like to have is, instead of asking the user to upload the canvas image, is it possible to get that image from another url, something like

    http://www.somedomain.com/canvasImage.jpg

  • Re: Image from URL

    01-14-2007, 11:40 PM
    • Loading...
    • Jigar
    • Joined on 06-17-2002, 5:41 AM
    • Ridgewood, NJ
    • Posts 935

    Yes it is possible.

    You will have to use HttpWebRequest and HttpWebResponse Object to get image stream from remote server and then use Bitmap constructor which takes stream

    However using image from other site without permission can you in trouble.

    Jigar Desai
    -----------------------
    Do not forget to "Mark as Answer" on the post that helped you.
  • Re: Image from URL

    01-15-2007, 7:29 PM
    • Loading...
    • miztiik
    • Joined on 10-22-2006, 1:19 AM
    • Hell
    • Posts 236

    we are planning to have the users upload images and use them as canvas images for creating their own images, and we dont intend to store any of them in our servers. so we think we will not end up with trouble with this structure.

    can i have a sample code for the HttpWebRequest Method

  • Re: Image from URL

    01-15-2007, 10:15 PM
    • Loading...
    • Jigar
    • Joined on 06-17-2002, 5:41 AM
    • Ridgewood, NJ
    • Posts 935
    HttpWebRequest myHttpWebRequest = (HttpWebRequest)WebRequest.Create(url);
    // Sends the HttpWebRequest and waits for the response.           
    HttpWebResponse myHttpWebResponse = (HttpWebResponse)myHttpWebRequest.GetResponse();
    // Gets the stream associated with the response.
    Stream receiveStream = myHttpWebResponse.GetResponseStream();
    Copied from http://msdn2.microsoft.com/en-us/library/system.net.httpwebresponse.getresponsestream.aspx
     
    										                
    										                
                									    
    Jigar Desai
    -----------------------
    Do not forget to "Mark as Answer" on the post that helped you.
  • Re: Image from URL

    01-17-2007, 6:53 PM
    • Loading...
    • miztiik
    • Joined on 10-22-2006, 1:19 AM
    • Hell
    • Posts 236
    is it possible to check the size of the image before uploading the entire file, something like validation.
  • Re: Image from URL

    01-17-2007, 8:07 PM
    • Loading...
    • Jigar
    • Joined on 06-17-2002, 5:41 AM
    • Ridgewood, NJ
    • Posts 935

    No, Browser can not get file size on client side (Security reason), You will have to uploade file on server to get file size.

    However JavaApplet or ActiveX control  can do that job.

    Jigar Desai
    -----------------------
    Do not forget to "Mark as Answer" on the post that helped you.
  • Re: Image from URL

    01-17-2007, 8:28 PM
    • Loading...
    • miztiik
    • Joined on 10-22-2006, 1:19 AM
    • Hell
    • Posts 236
    Not necessarily in the broswer. once we start geting  the first few bytes of the file, cant we determine the size of the file and proceed further accordingly?Surprise
  • Re: Image from URL

    01-17-2007, 9:04 PM
    • Loading...
    • Jigar
    • Joined on 06-17-2002, 5:41 AM
    • Ridgewood, NJ
    • Posts 935

    miztiik:
    Not necessarily in the broswer. once we start geting  the first few bytes of the file, cant we determine the size of the file and proceed further accordingly?Surprise

    You will have to wait untill you receive bytes that are more then your set limit and then stop receiving further, its not out of the box feature but you can do it with HttpModules.

    Also try this open source upload control http://www.brettle.com/neatupload it comes with source code which you can modify to suite your requirment.

    Jigar Desai
    -----------------------
    Do not forget to "Mark as Answer" on the post that helped you.
    Filed under: , ,
Page 1 of 1 (8 items)
Microsoft Communities
Page view counter