FileUpload and saving images from another site

Discussion in 'C#' started by RabBell, May 9, 2007.

  1. #1
    I'm trying to save an image from another web site to my server.

    First I was using a fileupload and then using the postedfile.saveas function to save the image from the users machine to the server and then add a reference to the database

    However I'm now using the manual add function with the Amazon eCommerce function. But the problem I'm having is how do I take an image from a web site (in this case Amazon) and save it on a server?

    I can get the URL for the image but can't see anyway to take that URL and use it to save a copy of the file to a specified location on my server.

    I've tried looking at the File, Image and Object objects but I can't see a solution.

    Any helps appreciated :)
     
    RabBell, May 9, 2007 IP
  2. ccoonen

    ccoonen Well-Known Member

    Messages:
    1,606
    Likes Received:
    71
    Best Answers:
    0
    Trophy Points:
    160
    #2
    Please post a url of the Image you are trying to download... and is it classic asp? .NET ?
     
    ccoonen, May 9, 2007 IP
  3. RabBell

    RabBell Guest

    Messages:
    7
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    it's not necessarily the image, it can be any image on the web, the image isn't important it's how do you save an image from the web to your server?

    Also this is ASP.Net
     
    RabBell, May 10, 2007 IP
  4. ccoonen

    ccoonen Well-Known Member

    Messages:
    1,606
    Likes Received:
    71
    Best Answers:
    0
    Trophy Points:
    160
    #4
    Create a WebClient object, then use it's DownloadFile method

    Dim WebObj as New WebClient()
    Dim RemoteFileLocation As String = "http://www.google.com/intl/en_ALL/images/logo.gif"
    Dim LocalFileLocation As String = "C:\logo.gif"
    Dim myWebClient As New WebClient()
    WebObj.DownloadFile(RemoteFileLocation, LocalFileLocation)

    This should do the trick me thinks :)
     
    ccoonen, May 15, 2007 IP
  5. lermann

    lermann Peon

    Messages:
    1
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #5
    is it possible to do the same with classic ASP?

    thanks
     
    lermann, Jun 5, 2007 IP