php - How can I understand the download is completed? -


i wrote simple download system php, should store size of downloaded files database can calculate bandwidth usage of user later, code :

<?php  $filename = _files_paths."/".$_get['file']; $type = getfiledata($filename); // wrote function return file type $size = filesize($filename); mysql_query("insert download_logs (user_id,filename,filesize) values (".$_session['user_id'].", '".$_get['file']."', '".$size."'"); header("content-type: ".$type); header("content-length: ".$size); header("content-disposition: attachment;filename=".$_get['file']); echo file_get_contents($filename);  ?> 

this code work without problem, maybe user cancel download operation before completion, store file size in database.

how can store downloaded bytes in database or if impossible, how can store file size after download completed ?


Comments

Popular posts from this blog

c++ - Creating new partition disk winapi -

Android Prevent Bluetooth Pairing Dialog -

php - joomla get content in onBeforeCompileHead function -