46
rated 0 times
[
49]
[
3]
/ answers: 1 / hits: 45859
/ 13 Years ago, wed, april 13, 2011, 12:00:00
Is there a way to make an image a download once you click on it (without right-click save image as)?
I'm using a small Javascript function to call the download page:
<a href=#
onclick=window.open('download.php?file=test.jpg', 'download', 'status=0');
>Click to download</a>
In the download.php page I have something like:
$file = $_GET['file'];
header('Content-Description: File Transfer');
header(Content-type: image/jpg);
header(Content-disposition: attachment; filename= .$file.);
readfile($file);
But it doesn't work. What am I doing wrong?
Thanks in advance!
More From » php