私はファイルのアップロードを行っているプロジェクトに取り組んでいます。これらのファイルにはランダムな名前が付けられ、Webディレクトリの外側に配置されます。ルーピング、ヘッダーセット...何も起こっていません
次に、絶対に問題のないURLに渡されたパラメータに基づいてこのイメージを取得するスクリプトを作成しました。
しかし、私はブラウザに渡したいヘッダーの配列を作成し、foreach
ループでこれらをループして、何も設定していないように見えました。しかし、私が手動でheader
関数を使ってそれらを設定すると、それらは機能します!奇妙な!
ここでは、ループする代わりにheader
関数を使用しても構いませんが、これが機能しない特定の理由がありますか?
また、上記の方法を使用して配列にすべてのヘッダーを格納し、コンテンツをブラウザに配信する際にそれらを処理しますが、実際に渡されているかどうかはわかりません。
私のコードのスニペット:場違いに見えるが
// Expiry date in seconds, in this instance a year
$expiry_date= (60 * 60 * 24 * 365);
// Our headers
$img_headers= array(
'Content-Type : ' . $mime,
'Cache-Control: no-cache, must-revalidate',
//'Cache-control: max-age=' . $expiry_date,
'Expires:' . gmdate(DATE_RFC1123, time() + $expiry_date),
'Pragma: ',
'Last-Modified: ' . gmdate(gmdate(DATE_RFC1123), filemtime($image_path)),
'Content-Length: ' . (string) filesize($image_path),
'Content-Disposition: inline; filename="' . $image_name . '"'
);
/*header('Content-Type: ' . $mime, TRUE);
header('Cache-Control: no-cache, must-revalidate', TRUE);
header('Expires: ' . gmdate(DATE_RFC1123, time() + $expiry_date));
header('Pragma: ', TRUE);
header('Last-Modified: ' . gmdate(gmdate(DATE_RFC1123), filemtime($image_path)), TRUE);
header('Content-Length: ' . (string) filesize($image_path), TRUE);*/
// Loop through and set up our headers!
foreach($img_headers as $new_header)
{
header($new_header, TRUE);
}
// Read our image and end the rest of the file execution
return die(readfile($image_path));
何か?
ありがとうございます!
そのスクラップは、私はそのコメントで自分自身の頭だった! 私はこのような単純なエラーを逃したと信じられません! *ありがとうございます。ありがとうございました!私は今、本当に馬鹿だと感じる!虚 – Azirius