Download файлов, хелп

Serrrgio

Новичок
Download файлов, хелп

PHP:
header ("Content-type: image/jpeg");
if (isset($_GET['sm'])) {
  $image = exif_thumbnail($path."/".$fl);

if ($image!==false) {
echo $image;
} else {
if (is_file($path."/sm/".$fl)) {
echo file_get_contents($path."/sm/".$fl);
} else {
imagepng (imagecreatefrompng ("./img/no.png"));
}}} else {
//  exit;
$len = filesize($path."/".$fl);
header("Content-Length: $len");
header("Content-Disposition: attachment; filename=\"".$fl."\";");

$handle = fopen($path."/".$fl, "rb");
 while(!feof($handle)) {
     $buf = fread($handle,1024000);
     echo $buf;
     flush();
 }
 fclose($handle);
}
иногда (по неизвестной причине) файлы бьются - http://rghost.ru/3111456

такой же скрипт только с другими заголовками отдает архив ~40 Мб, архив приходит с ошибками (размер файла одинаковый, ошибка в самих данных)...

что может быть, куда копать?

ЗЫ: PHP Version 5.1.2, Linux ххх.ххх 2.6.17-1.2157.1asp #1 Fri Aug 11 03:02:11 EEST 2006 i686
 

PHProgress

Новичок
Делаю так:

PHP:
$file = $_GET['pachfile'];
$typfile = end(explode(".", $file));	//1. узнаем расширение файла

if (file_exists($file) /* 2. Провераяем наличие файла */) {
    header('Content-Description: File Transfer');
    header('Content-Type: application/octet-stream');
    header('Content-Disposition: attachment; filename='.basename($file));
    header('Content-Transfer-Encoding: binary');
    header('Expires: 0');
    header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
    header('Pragma: public');
    header('Content-Length: ' . filesize($file));
    ob_clean();
    flush();
    readfile($file);
    exit;
}
else {  }
 

mustafa

Новичок
>>$typfile = end(explode(".", $file));
не делай так, делай так:
filetype($filename)
 
Сверху