Php 力';另存为';svg文件
我有以下文件: 下载.phpPhp 力';另存为';svg文件,php,Php,我有以下文件: 下载.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($pa
<?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_文件文件夹中。但当我跑步时:
myweb.com/svg\u files/download.php?filename=file.svg
我只得到一个空文件。您必须将文件内容输出到浏览器。。 使用
readfile
或file\u获取内容
和echo
或类似方法
作为旁注:注意所谓的目录遍历攻击。你可能需要采取一些预防措施。