Page 1 of 1
archive files are corrubted if i download it with header()
Posted: Wed Nov 25, 2009 5:51 pm
by trazan
i use this code to download files but i found the archive files corrubted
i download it directly and it was good and this in the localhost and in my Site do you know how can i solve it
Code: Select all
header("Pragma: public");
header("Expires: 0");
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
header("Cache-control: public");
header("Content-Description: File Transfer");
header('HTTP/1.1 206 Partial Content');
header('Accept-Ranges: bytes');
header("Content-Transfer-Encoding: binary");
header("Content-length: ".filesize($filename));
header('Content-type: application/zip');
header("Content-Disposition: attachment; filename=\"" . basename($filename) . "\"");
Re: archive files are corrubted if i download it with header()
Posted: Thu Nov 26, 2009 1:10 am
by trazan
any help!!!!!!!!!
Re: archive files are corrubted if i download it with header()
Posted: Thu Nov 26, 2009 7:11 pm
by trazan
Re: archive files are corrubted if i download it with header()
Posted: Thu Nov 26, 2009 7:35 pm
by requinix
Where's the code that outputs the file?
Re: archive files are corrubted if i download it with header()
Posted: Thu Nov 26, 2009 7:42 pm
by trazan
that is the code as u see i use this code to limtied the speed of download and i put it after the header function
Code: Select all
$file = fopen($filename, "r");
while(!feof($file)) {
// send the current file part to the browser
print fread($file, round($download_rate * 1024));
// flush the content to the browser
flush();
// sleep one second
sleep(1);
}
// close file stream
fclose($file);
}
Re: archive files are corrubted if i download it with header()
Posted: Thu Nov 26, 2009 9:13 pm
by requinix
For compatibility with Windows use
How does the size of the downloaded file compare with the original file?
Re: archive files are corrubted if i download it with header()
Posted: Thu Nov 26, 2009 10:19 pm
by trazan
For compatibility with Windows use
I Am Linux User
____
How does the size of the downloaded file compare with the original file?
ohh i just notic that when i puse the download and resume it again the download wil start the download for the file from the begining but he will write on the same file on the pc
exapmle : if i download file.zip ( 10 M.B ) and pused the download in 50% and resumed it again i will found the final file size 15 M.B
now you have the code , does any one knoe what i can do for that
Re: archive files are corrubted if i download it with header()
Posted: Thu Nov 26, 2009 10:46 pm
by requinix
trazan wrote:I Am Linux User
That's nice, but make the change anyways. It's called "planning ahead".
You've only gone halfway between a regular download script and one that lets you pause and resume. Halfway means you get some of one and some of the other - and that means you don't have a fully functional script.
For a regular download comment out the HTTP/1.1 206 and the Accept-Ranges headers.
For a resumeable download you'll need more work. Work that's outside the scope of this thread right now.
trazan wrote:ohh i just notic that when i puse the download and resume it again the download wil start the download for the file from the begining but he will write on the same file on the pc
exapmle : if i download file.zip ( 10 M.B ) and pused the download in 50% and resumed it again i will found the final file size 15 M.B
Given the code you have, that's absolutely correct behavior.
Without pausing the download, what is the size of the file you get and what is the size of the original file? Are they the same or are they different?
Re: archive files are corrubted if i download it with header()
Posted: Sat Nov 28, 2009 6:46 am
by trazan
Given the code you have, that's absolutely correct behavior.
Without pausing the download, what is the size of the file you get and what is the size of the original file? Are they the same or are they different?
Without pausing the download the file size is correct and it is not corrubted
