0

Possible Duplicate:
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

Community
  • 1
  • 1
AnchovyLegend
  • 12,139
  • 38
  • 147
  • 231
  • 2
    I think you should simply generate the file when the user is clicking on the download link and not before – Gilles Hemmerlé Jan 14 '13 at 13:57
  • I appreciate the reply and I agree, but assuming I would like to take this approach, is it possible to somehow detect when a user made a decision on the 'save as' dialog? – AnchovyLegend Jan 14 '13 at 13:58

2 Answers2

0

There is no way to determine whether a user has downloaded the file or not.

In your case, just don't save the file. Generate it into a string and send this one along with appropriate headers.

Martin Müller
  • 2,565
  • 21
  • 32
0

There is no way to check if user has finished to download file or has paused it. But you can delete if in 24 hour after download was started.

Or your can generate a file, encode it with base64 and send as a page.

primetwig
  • 465
  • 3
  • 12