私のファイル(126 MBのサイズ、.exe)は私に問題を与えています。Laravelで大きなファイルを簡単にダウンロードできないのはなぜですか?
私は標準のlaravelダウンロード方法を使用しています。
メモリを増やしてみましたが、メモリが不足しているとか、0KBのサイズのファイルをダウンロードしているというメッセージが表示されます。
ドキュメントには大きなファイルサイズについての記載はありません。
私のコードは私が間違っているの
ini_set("memory_limit","-1"); // Trying to see if this works
return Response::download($full_path);
何ですか?編集 - -
フィルスパークスコメントに行くが、これは私が持っているものであるとそれがに動作します。 PhillとPhp.netの組み合わせです。 不足しているものがあるかどうか不明ですか?
あなたは、私が期待しini_set('memory_limit','128M');
これはあなたのために働くだろう例えばini_set関数を使用してのmemory_limitを増やす必要があります:あなたはそうのようなあなたのmemory_limitを増やす必要があり
public static function big_download($path, $name = null, array $headers = array())
{
if (is_null($name)) $name = basename($path);
// Prepare the headers
$headers = array_merge(array(
'Content-Description' => 'File Transfer',
'Content-Type' => File::mime(File::extension($path)),
'Content-Transfer-Encoding' => 'binary',
'Expires' => 0,
'Cache-Control' => 'must-revalidate, post-check=0, pre-check=0',
'Pragma' => 'public',
'Content-Length' => File::size($path),
), $headers);
$response = new Response('', 200, $headers);
$response->header('Content-Disposition', $response->disposition($name));
// If there's a session we should save it now
if (Config::get('session.driver') !== '')
{
Session::save();
}
// Below is from http://uk1.php.net/manual/en/function.fpassthru.php comments
session_write_close();
ob_end_clean();
$response->send_headers();
if ($file = fopen($path, 'rb')) {
while(!feof($file) and (connection_status()==0)) {
print(fread($file, 1024*8));
flush();
}
fclose($file);
}
// Finish off, like Laravel would
Event::fire('laravel.done', array($response));
$response->foundation->finish();
exit;
}
ほとんどの場合、readfileとfpassthru()の両方でファイルが見つかりませんでした。しかし、私はリンクを見て、それをあなたのものと組み合わせて働くものを作りました。それがどれほど正しいのか分かりませんが?最新の情報を表示するために質問を編集しました。 – Lango
こんにちは@Lango、私はあなたのソリューションには問題が表示されません。 fread + printのアプローチと 'ob_get_clean()'も含めるように答えを更新しました。 fread + printが同じファイルポインタを使うので、なぜfpassthruがうまくいかないのかわかりませんが、それがあなたのために働くのであれば、ロールしてください! –
ありがとうPhill!それはすべて今働いている。 – Lango