Reply to Re: Having problem while downloading some files.

Your name:

Reply:


Posted by just.starting@gmail.com on 01/12/06 23:54

This is the code I am using now, and I am able to download only bytes
with length n*chunk_size where n is a number, like I am unable to get
the last few bytes.

for examle if the filesize is 400 bytes and i use 256 bytes as
chunksize I am getting only 256 bytes and then the connection is being
closed. what is happening here. Is there any problem with the code. BTW
I tried the same code at another machine and it works perfectly OK.

$download_size = filesize($fullpath);

header("Pragma: public");
header("Expires: 0");
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
header("Cache-Control: private",false);
header("Content-Type: $contenttype;");
header("Content-Disposition: attachment;
filename=\"".basename($file_name)."\";" );
header("Content-Transfer-Encoding: binary");
header("Content-Length: ".$download_size);
while (ob_get_level()) {
ob_end_flush();
}
// start output buffering
if (ob_get_length() === false) {
ob_start();
}
$chunksize = 256; // how many bytes per chunk
$buffer = '';
$handle = fopen($filename, 'r');
if ($handle === false) {
return false;
}
$count = 0;
while (!feof($handle)) {
set_time_limit(0);
echo fread($handle,$chunksize);
ob_flush();
flush();
}
ob_end_flush();

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация