Hello i am trying to record how much the user has downloaded when the user aborts the script i want the script to be able to save a text file with information how much they have downloaded with this i will have an idea how to create a quota program, i have tried fopen, fread works grate only one problem it i ant seek for the file, curl does the job i want to be able to log bytes when the user aborts the script or something like that, or when the user is downloading at the same time log the information to a text file.
function log_this($line) { $filename = 'download_log.txt'; $handle = fopen($filename, 'a'); fwrite($handle, $line . "\n"); } $var = "http://rarlabs.com/rar/wrar393.exe"; $ch = curl_init($var); $filename = basename($var); @header("Cache-Control:"); @header("Cache-Control: public"); @header("Content-Type: application/octet-stream"); @header("Content-Disposition: attachment; filename=".$filename); @header("Accept-Ranges: bytes"); echo curl_exec($ch); if(!connection_aborted()) { $info = curl_getinfo($ch); $downloaded = $info[size_download]; log_this($downloaded); }