내 클라이언트가 웹 사이트를 다소 멋진 서버에서 ...로 이동 시키기로 결정한 경우 ... 덜 훌륭한 서버라고 부릅니다.PHP에서 파일 다운로드, 메모리 제한 문제가 있습니까?
문제가는 또한 더욱 어렵게 나를 위해, 그들은 fopen을 허용하지 않습니다하려면 32입니다 ...
을 다운로드 할 40MBs으로 파일 서버의 메모리 제한이 파일 크기를 20MB로 줄이면 제대로 작동합니다.
내 질문은, 내가 할 수있는 - 파일 크기를 줄이는 것 외에도 -이 작품을 만들 수 있습니까?
당신에게편집 감사합니다`
$fsize = filesize($file_path);
$path_parts = pathinfo($file_path);
$ext = strtolower($path_parts["extension"]);
switch ($ext) {
case "pdf": $ctype = "application/pdf";
break;
case "exe": $ctype = "application/octet-stream";
break;
case "zip": $ctype = "application/zip";
break;
case "doc": $ctype = "application/msword";
break;
case "xls": $ctype = "application/vnd.ms-excel";
break;
case "ppt": $ctype = "application/vnd.ms-powerpoint";
break;
case "gif": $ctype = "image/gif";
break;
case "png": $ctype = "image/png";
break;
case "jpeg":
case "jpg": $ctype = "image/jpg";
break;
default: $ctype = "application/force-download";
}
header("Pragma: public"); // required
header("Expires: 0");
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
header("Cache-Control: private", false); // required for certain browsers
header("Content-Type: $ctype");
header("Content-Disposition: attachment; filename=\"" . basename($file_path) . "\";");
header("Content-Transfer-Encoding: binary");
header("Content-Length: " . $fsize);
ob_clean();
flush();
readfile($file_path);`
내가 php.net
// If it's a large file, readfile might not be able to do it in one go, so:
$chunksize = 1 * (1024 * 1024); // how many bytes per chunk
if ($size > $chunksize) {
$handle = fopen($realpath, 'rb');
$buffer = '';
while (!feof($handle)) {
$buffer = fread($handle, $chunksize);
echo $buffer;
ob_flush();
flush();
}
fclose($handle);
} else {
readfile($realpath);
}
phpinfo의 핵심 부분은 어떤 모양입니까? 붙여 줄래? 빠른 수정을 원할 경우 .htaccess 파일을 사용하여 PHP 설정을 변경할 수 있습니다. 그것들은 드루팔 (drupal) 문서이지만, 드루팔 (drupal)과 관련이 없습니다. http://drupal.org/node/29268 및 http://drupal.org/node/97193 – KyleWpppd
특히 어떤 부분입니까? (여기에 모든 것을 게시하는 것이 다소 중요합니다.) –
php.net의 코드가 잘 수행되어야합니다. 그냥 사용하지 않으면 ob_ ..을 제거하십시오. ob 인 경우 gz를 추가하여 빠른 다운로드를 고려하십시오. – Teson