I am trying to force a download. here is my code:
// Define the path to file
$file = 'http://myimage.com/users/test/uploads/1234.png';
// File doesn't exist, output error
die('file not found');
header('Content-disposition: attachment; filename='.$file);
here is the error that I get in firefox: "The image "file:///C:/Users/Username/Downloads/1234%20(4).png" cannot be displayed because it contains errors."
the %20(4) is a space, and probably the 4th copy i've tried downloading.
Content-Type is wrong. All that's needed to force a download is
Content-Disposition: attachment; change it to
image/png instead of
Also, you have a space before your opening
<?php tag. You need to take that out.
Also, your "file exists" check doesn't do what you think it does. Use
file_exists to check if a file exists, and remember the
Ensure you don't have any blank lines outside the