Download header for image

Thursday, July 19, 2012

print this page
send email












Below code will download image from the link stored in $main_url.This code uses curl library.
<?php
$main_url='http://24.224.243.223/axis-cgi/jpg/image.cgi?resolution=640x480&camera=1&compression=25';
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL,$main_url);
curl_setopt($curl,CURLOPT_POST,1);
curl_setopt($curl,CURLOPT_POSTFIELDS,$requr);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
$result = curl_exec ($curl);
$err = curl_error($curl);
curl_close ($curl);
header('Content-type:image/jpeg');
header('Content-Disposition:attachment;filename="cam.jpg"');
echo $result;
?>


Happy coding :)

0 comments:

Post a Comment