hi folks!
i was trying to write a downloadscript that would log some data, but
only if the download was succesfull (the user did not hit the 'cancel'-button).
the 'standart' download-procedure is no problem, i can easily add the
necessary headers, send the file and it gets downloaded without a problem.
what i am missing is some way to detect if the download was canceled or got
interrupted.
i've tried some possible solutions, but none of them worked:
a) passing the file to the browser via readfile("test.zip"):
i thought that when the user hits 'cancel' the script should stop,
thus not executing the code that would log the data.
this works on my localhost (php as cgi on apache/win98), but not on
my webspace (php module on apache/redhat linux).
it seems that the whole script is executed, no matter if it is canceled while
sending the data.
b)passing the file via fpassthru($filehandle):
same problem, tried
if (fpassthru($file_handle)) {
//some code here to log data
}
but this did not work, too.
the third solution should work, but imho is using too much ressources:
checking the server logs, comparing the size of the data send to the size
of the file on the server -> if the file on the server is bigger than the data
send it is obvious that the download was not completed. but i would have
to parse the whole log, which is a bit too heavy, i think.
do you know of any other (maybe easier) solution to this problem?
thanx in advance ;o)
martin