You are here: check if file was downloaded « PHP Programming Language « IT news, forums, messages
check if file was downloaded

Posted by Hendri Adriaens on 02/23/07 14:17

Hi,

I use the following code to offer a download:

header("Content-Type:$mimetype");
header("Content-Disposition: attachment; filename=$filename");
header("Cache-Control:must-revalidate,post-check=0,pre-check=0");
header("Content-Length:".filesize($temp_filename));
readfile_chunked($temp_filename);

(readfile_chunked comes from
http://nl2.php.net/manual/nl/function.readfile.php)

My question: how can I check if the file was downloaded and saved? I want to
make an automatic removal possible after download.

The function seems to exit when the user clicks cancel and doesn't download
the file, so all following commands will not get executed. That's perfect.

However, it doesn't when the file is small enough to fit in a chunk. php's
readfile seems to have the same behaviour. So, in that case, all following
commands do get executed, even if cancel was clicked (and in my application,
the file then gets removed, which shouldn't happen of course).

Also checking the bytes sent doesn't help. If the function exists, it always
returns the complete filesize for the small files that fit in a single
chunk, even if cancel was clicked.

So, is there any working way to determine if a file was downloaded and
opened/saved instead of cancel being clicked in the download dialog?

Thanks in advance, best regards,
-Hendri Adriaens.

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация