我下载了一个文件,但它给出了无效的文件作为回报。
这是我的download_content.php
<?php
$filename = $_GET["filename"];
$buffer = file_get_contents($filename);
/* Force download dialog... */
header("Content-Type: application/force-download");
header("Content-Type: application/octet-stream");
header("Content-Type: application/download");
/* Don't allow caching... */
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
/* Set data type, size and filename */
header("Content-Type: application/octet-stream");
header("Content-Transfer-Encoding: binary");
header("Content-Length: " . strlen($buffer));
header("Content-Disposition: attachment; filename=$filename");
/* Send our file... */
echo $buffer;
?>
下载文件链接:
<a href="download_content.php?filename=/gallery/downloads/poster/large/'.$r['file'].'"> Download</a>
$r['file']
包含要下载的文件名。
包含该文件的文件夹的完整路径是:
localhost/ja/gallery/downloads/poster/large/'.$r['file'].'
ja
是中的根文件夹htdocs
。
我不知道实际问题是什么,有人可以帮助我吗?