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!