Thursday, 28 January 2016

Download image from url php curl

From Curl we can request to other site to grab all data which is in form of JS html and so on
in this example i want to shows that how to fetch images from other URL
By CURL we can get all HTML from other URL then i substracted that all images from that content and display data and image both in Proper way in our page without redirect on other sites

From cURL

    $ch = curl_init();
    curl_setopt($ch, CURLOPT_HEADER, 0);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($ch, CURLOPT_URL, "WEBSITE URL");
    curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);

    $data = curl_exec($ch);

which return to us data in form on Html  ,

    $info = curl_getinfo($ch, CURLINFO_CONTENT_TYPE);

Like