File download probs...
Posted: Mon Feb 19, 2007 4:04 pm
I am working on a shopping cart at the moment and I am wondering if it is possible to determine whether a file has been downloaded so I can update the database. It is fairly difficult to explain but look at the code below:
It works well yes, however if the user presses cancel instead of download when the "download file" dialog pops up the query still runs?. Is it possible to make it so if they do press cancel, then the query will not run?
Thanks
Code: Select all
header('Content-Description: File Transfer');
header('Content-Type: application/force-download');
header('Content-Length: ' . filesize($file));
header('Content-Disposition: attachment; filename=' . basename($file));
readfile($file);
$sql_query_mark_download = "UPDATE `videofiles` SET `downloaded`='1' WHERE `id` = '" . $_REQUEST['did'] . "'";
mysql_query($sql_query_mark_download) or die(mysql_error());Thanks