Hello, I have the following script, which should work 100% in theory, but it just dosnt. if (file_exists($fileUrl)) { $fileSize = (string)(filesize($fileUrl)); header ("Content-Type: video/avi"); header ("Content-Length: ".$fileSize); header ('Content-Disposition: attachment; filename="Psych-Season'.$season.'Episode'.$episode.'.avi"'); readfile($fileUrl); exit(); } PHP: I works, and sends the file to the user, but there is no progress bar when downloading. This should have been fixed by header ("Content-Length: ".$fileSize); PHP: but it isnt. Please help me out
can u print the value of filesize if its printing the values correctly try this alternative (file_exists($fileUrl)) { header("Content-type: application/octet-stream\n"); header("Content-disposition: attachment; filename=\"".$fileUrl."\"\n"); header("Content-transfer-encoding: binary\n"); header("Content-length: ".filesize($fileUrl)."\n"); $fp = fopen($fileUrl, "rb"); while(!feof($fp)) { $buffer = fread($fp, 4096); print $buffer; } fclose($fp);
Here is what I get when I run die($fileSize); PHP: 365697024 Tried... same problem Tried adding \n to each header, didnt help. I was searching for this online and came upon this: Source: http://www.w3.org/Protocols/rfc2616/rfc2616-sec4.html#sec4.4 I have no idea what it means, but it does mention ignoring the content-length, so im assuming it is relevant. Can you shed any light on this?