0

次のファイルがあります。

ダウンロード.php

<?php 

$filename = $_GET["filename"];

if ($filename) {
$path = "/svg_files/".$filnavn."";
header('Content-Transfer-Encoding: binary');  // For Gecko browsers mainly
header('Last-Modified: ' . gmdate('D, d M Y H:i:s', filemtime($path)) . ' GMT');
header('Accept-Ranges: bytes');  // For download resume
header('Content-Length: ' . filesize($path));  // File size
header('Content-Encoding: none');
header('Content-Type: application/svg');  // Change this mime type if the file is not PDF
header('Content-Disposition: attachment; filename=' . $filename);  // Make the browser display the Save As dialog
}
?>

これは svg_files フォルダーにあります。しかし、私が実行すると:

myweb.com/svg_files/download.php?filename=file.svg

空のファイルを取得するだけです。

4

1 に答える 1

1

ファイルの内容をブラウザに出力する必要があります。readfileor file_get_contentsand echoor を使用してください。

補足: いわゆるディレクトリ トラバーサル攻撃に注意してください。予防策を講じる必要があるかもしれません。 http://en.wikipedia.org/wiki/Directory_traversal_attack

于 2012-10-25T10:41:36.583 に答える