Copy link to clipboard
Copied
I am trying to let a user download a file. here is my code:
<?PHP
// Define the path to file
$file = 'http://www.media.lonelyplanet.com/lpi/12553/12553-11/469x264.jpg';
if(!file)
{
// File doesn't exist, output error
die('file not found');
}
else
{
header('Content-Description: File Transfer');
header('Content-Type: application/octet-stream');
header('Content-Disposition: attachment; filename='.basename($file));
header('Content-Transfer-Encoding: binary');
header('Expires: 0');
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
header('Pragma: public');
header('Content-Length: ' . filesize($file));
ob_clean();
flush();
readfile($file);
exit;
}
?>
why doens't it download properly? when you attempt to download it, the file is unreadable.
Copy link to clipboard
Copied
There isn't an image located at http://www.media.lonelyplanet.com/lpi/12553/12553-11/469x264.jpg
Try this: http://media.lonelyplanet.com/lpi/12553/12553-11/469x264.jpg
best,
Shocker ![]()
Find more inspiration, events, and resources on the new Adobe Community
Explore Now