Updating a table after a successful download
| From: | Luis Lebron | Date: | Wed, 30 Jul 2003 12:44:00 +0000 |
| Subject: | Updating a table after a successful download | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-157513@lists.php.net to get a copy of this message | ||
I currently have some code in a document management system that is used to
check-out a document.
It looks like this:
//Update the status of the document
$query = "UPDATE $table_data SET status = '$SESSION_UID' WHERE id =
'$id'";
$result=&$conn->Execute($query);
//Download the document.
header ("Content-Type: application/octet-stream");
header ("Content-Disposition: attachment; filename=$realname");
readfile($filename);
The problem I am having is that when the download is canceled by the user
the document still shows up as being checked out. Is there a way to know if
the document has been successfully downloaded before I update the database.
Something like:
//Download the document.
header ("Content-Type: application/octet-stream");
header ("Content-Disposition: attachment; filename=$realname");
readfile($filename);
//Determine if download is successful????. Set download variable.
if($download=1)
{
//Update the status of the document
$query = "UPDATE $table_data SET status = '$SESSION_UID' WHERE id =
'$id'";
$result=&$conn->Execute($query);
}
thanks,
Luis R. Lebron