[HELP] Get Images From Https

Discussion in 'PHP' started by sumarjan, Jan 20, 2012.

  1. #1
    I have use this code to grab image from google doc:

    <?php

    $contents= file_get_contents('https://docs.google.com/viewer?pid=bl&srcid=ADGEESiNAm1AqndlL9zNQjsmuN0mVc2Xnror_7uT2y0TFHMyvWwYCZ7TwJ0PkHHBksLvkzz3HiHSBPIABnst5PsHwHdCaR5REXe6HLRFPwisoMJE6SnmUUxJoKwHMx78HB4nBsKWvayE&q=cache%3ASzO-xVwTZpEJ%3Ahttps%3A%2F%2Ftechinfo.honda.com%2Frjanisis%2Fpubs%2Fom%2FTK0707%2FTK0707MAINIXA.pdf%20Acura%20Rdx%20Manual%20filetype%3Apdf&docid=f571b69d570bb647ddb4c4e4ee723393&a=bi&pagenumber=1&w=800');

    $savefile = fopen('images/image.jpg', 'w');
    fwrite($savefile, $contents);
    fclose($savefile);

    ?>

    But it showing error message:

    Warning: file_get_contents(https://docs.google.com/viewer?pid=...bb647ddb4c4e4ee723393&a=bi&pagenumber=1&w=800) [function.file-get-contents]: failed to open stream: HTTP request failed! HTTP/1.0 400 Bad Request in C:\AppServ\www\_coba\SaveImageFromUrl.php on line 35


    Can anyone help me please???

    thanks
     
    sumarjan, Jan 20, 2012 IP
  2. animedbsellersz

    animedbsellersz Well-Known Member

    Messages:
    276
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    123
    #2
    use curl,
    i pm you the code
     
    animedbsellersz, Jan 20, 2012 IP
  3. gherca

    gherca Member

    Messages:
    50
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    38
    #3
    sumarjan , you can`t use file_Get_contents for this, need curl with CURL_SETOPT REDIRECT true . This need :)
     
    gherca, Jan 20, 2012 IP
  4. sumarjan

    sumarjan Active Member

    Messages:
    129
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    51
    #4

    thanks for your nice code..
    i will try and report ;)
     
    sumarjan, Jan 21, 2012 IP
  5. sumarjan

    sumarjan Active Member

    Messages:
    129
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    51
    #5
    thanks for reply and suggestion ;)
     
    sumarjan, Jan 21, 2012 IP