Post_action only when the download is completed

i have a problem with post_action on nginx.conf.
And sorry for my bad English :slight_smile:

User come to my page an start a download.
Now i have add the post_action and add the download_end.php
in the download_end.php i will count the download stats (write into
That work very beautifully without any error.

The problem is now, when the user cancel the download
download_end.php will execute, but thats false!

Only when the download is realy completed, than i will open
but NOT when the user canceled the download!

Are there any tricks?

Thank you for your help

   location /files/ {
       alias /home/files/;
       post_action /download-stop;

   location /download-stop {
       fastcgi_param SCRIPT_FILENAME

fastcgi_param QUERY_STRING file_id=$file_id; //thats ok!
fastcgi_param REMOTE_ADDR $remote_addr;