|
Posted by Chris Bruce on 05/13/05 18:19
I did look at your post on PATH_INFO which did not get me any closer to
the solution. At this point, I am just trying to get an image using
cURL and then force it to download to the computer. Here is the link:
http://205.207.224.90/getimage.php
and here is the code:
header("Content-type: image/jpg");
Header('Content-Disposition: attachment;
file="tigershippingdashboard20050429.jpg"');
$ch = curl_init(); // create cURL handle (ch)
if (!$ch) {
die("Couldn't initialize a cURL handle");
}
// set some cURL options
$ret = curl_setopt($ch, CURLOPT_URL,
"http://images.apple.com/home/2005/images/
tigershippingdashboard20050429.jpg");
$ret = curl_setopt($ch, CURLOPT_HEADER, 1);
$ret = curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
$ret = curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$ret = curl_setopt($ch, CURLOPT_BINARYTRANSFER, 1);
$ret = curl_setopt($ch, CURLOPT_TIMEOUT, 30);
// execute
$ret = curl_exec($ch);
if (empty($ret)) {
// some kind of an error happened
die(curl_error($ch));
curl_close($ch); // close cURL handler
}
else {
$info = curl_getinfo($ch);
curl_close($ch); // close cURL handler
if (empty($info['http_code'])) {
die("No HTTP code was returned");
}
else {
// load the HTTP codes
// echo results
echo "The server responded: <br />";
print "<pre>";
print_r($info);
print "</pre>";
}
}
I have tried changing the values of the curl options to no avail. What
ends up happening is the the PHP file is what gets downloaded with all
the binary data for the image in it. I need to find a way of getting
just the image to download.
In this example, I just want the image
tigershippingdashboard20050429.jpg to download.
Any ideas?
Thanks
Chris
> If you want to support older browsers, on more platforms, you would do
> well to look at another thread from yesterday where I talk about about
> PATH_INFO.
Navigation:
[Reply to this message]
|