> 
> **Possible Duplicate:**  
> 
> [How to detect when a user has successfully finished downloading a file in php](https://stackoverflow.com/questions/194579/how-to-detect-when-a-user-has-successfully-finished-downloading-a-file-in-php) 
> 
> 
> 

I was wondering if there is a way to detect whether a user downloaded a file?

I am creating a .docx file on the server, once the user clicks the 'download' button, and allowing them to download the file as shown below. What I am trying to do is delete the file once the bytes that define the file were sent out to the user. Is this possible?

```
$objWriter-> save('docxFiles/'.$filename);
echo '<script type="text/javascript">window.location.href=\'docxFiles/'.$filename.'\'</script>';

```

Many thanks in advance