php - file size not shown before download start

638

Here is my code in php : sample demo capture **Download worked but file size not showed size **

$infofile="sample.rar";
header("Content-Description:File Transfer");
header("Content-Type:application/x-rar");
header("Content-Lenght:".(string)filesize($infofile));
header("Content-Disposition:attachment;filename=sample_filename_for_dowload.rar");
header("Expires:0");
header("Cache-Control:must-revalidate,post-check=0,pre=check=0");
header("Progma:public");
ob_clean();
flush();
readfile($infofile);
484

Answer

Solution:

Maybe because of your typo

Content-lenght

Should be Content-Length http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html

People are also looking for solutions to the problem: php - My $_SESSION variables are only getting the first letter of each index in my array

Source

Didn't find the answer?

Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.

Ask a Question

Write quick answer

Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.

Similar questions

Find the answer in similar questions on our website.