filesize() will not return a meaningful value.
You have binary data in $file , not the actual file name as needed as the first parameter. Therefore, you will get an error. (Enable error_reporting! Do not see errors, and not have two different things.)
So you want to use strlen($file) , not filesize() .
Btw, application/octet-stream or other fills cannot be used to force download. This is the Content-Disposition: header, which is most important for this. You can still send the correct MIME type.
mario source share