I have a quick script that I wrote to display some images in a gallery format. I wanted to track the views of each image, so instead of directing linking each thumbnail to the larger image, i linked it to a php file which updated a database field and then redirects to the image using headers.
The problem is, after the image is now opened in the browser window, and you go to save it, it doesn't save as the proper image type. In firefox, it will always save as a PHP file, and IE, always a bitmap (when they are jpg's).PHP Code:
$id = $_GET['image'];
mysql_query("UPDATE downloads SET downloads= downloads + 1 WHERE id = '$id'");
$sql = mysql_query("SELECT link FROM downloads WHERE id = '$id'");
$row = mysql_fetch_object($sql);
header("Location: " . $row->link);
For example, visit here. Click on an image, and then right click and try to "save image as". You should notice the problem there.
Any help is appreciated. Thanks!