Making a web request to server, returning an image to the browser

Discussion in 'PHP' started by Arrowx7, Jun 24, 2008.

  1. #1
    Hi Everyone,
    I am trying to make a web request to a remote server with specific POST request parameters (making a request in PHP). The server returns an image, which I have to write to the browser.

    I know I can use the WebRequest class to make the request, but can anyone suggest how I can do the latter? How can I get the image from the server and print it to the browser screen? Can I get a stream out of the response object?

    If anyone can help me or point me in the right direction, I would greatly appreciate it!!
    Thanks, and take care!

    AR
     
    Arrowx7, Jun 24, 2008 IP
  2. Danltn

    Danltn Well-Known Member

    Messages:
    679
    Likes Received:
    36
    Best Answers:
    0
    Trophy Points:
    120
    #2
    Use curl to get the file. Extremely easy if you use curl_setopt($ch, CURL_POSTFIELDS, $post_fields); (Think I remembered that correctly, and then set use post to yes.

    All basic.

    Then use header('Content-type: image/png)' if it's PNG, etc. and just echo the image.

    Not too hard, good luck.

    Dan
     
    Danltn, Jun 24, 2008 IP