我在html代码里<br><a href="/hr/doc/download">{.filename}</a>
通过这个想传递给php页面的download方法一个参数,就是文件名,但我不知道这个{.filename}这个怎么传给如下的方法
中的$filename这个参数 function download($filename,$path,$content_type='application/octet-stream'){
if(strlen($filename) < 0)
{
}
if(strlen($path) < 0 )
{
$path = WWWPATH.'/upload/documents/';
}
ob_clean();
header('Pragma: public');
header('Last-Modified: '.gmdate('D, d M Y H:i:s') . ' GMT');
header('Cache-Control: no-store, max-age=0, no-cache, must-revalidate'); // HTTP/1.1
header('Cache-Control: post-check=0, pre-check=0', false);
header('Cache-Control: private');
header('Content-Transfer-Encoding: none');
header('Content-Disposition: attachment; filename='.$filename.'');
header('Content-Type: '.$content_type.'; name="'.$filename.'"');
echo file_get_contents($path);
exit;
}
通过这个想传递给php页面的download方法一个参数,就是文件名,但我不知道这个{.filename}这个怎么传给如下的方法
中的$filename这个参数 function download($filename,$path,$content_type='application/octet-stream'){
if(strlen($filename) < 0)
{
}
if(strlen($path) < 0 )
{
$path = WWWPATH.'/upload/documents/';
}
ob_clean();
header('Pragma: public');
header('Last-Modified: '.gmdate('D, d M Y H:i:s') . ' GMT');
header('Cache-Control: no-store, max-age=0, no-cache, must-revalidate'); // HTTP/1.1
header('Cache-Control: post-check=0, pre-check=0', false);
header('Cache-Control: private');
header('Content-Transfer-Encoding: none');
header('Content-Disposition: attachment; filename='.$filename.'');
header('Content-Type: '.$content_type.'; name="'.$filename.'"');
echo file_get_contents($path);
exit;
}
<html>
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
</head>
<body>
<br><a href="download.php?filename=abc.txt&path=a">{.filename}</a>
</body>
</html>
download.php<?phpfunction download($filename, $path, $content_type='application/octet-stream') { if (strlen($filename) < 0) {
}
if (strlen($path) < 0) {
$path = WWWPATH . '/upload/documents/';
} ob_clean();
header('Pragma: public');
header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');
header('Cache-Control: no-store, max-age=0, no-cache, must-revalidate'); // HTTP/1.1
header('Cache-Control: post-check=0, pre-check=0', false);
header('Cache-Control: private');
header('Content-Transfer-Encoding: none');
header('Content-Disposition: attachment; filename=' . $filename . '');
header('Content-Type: ' . $content_type . '; name="' . $filename . '"');
echo file_get_contents($path);
exit;
}$filename = $_GET['filename'];
$path = $_GET['path'];
if ($filename && $path) {
download($filename, $path);
}
?>
<br><a href="/hr/doc/download?filename={.filename}">{.filename}</a>//不知道楼主用的什么编辑器,但我猜{.filename}应该是php代码,就是把filename参数拼到url里面在你的函数里面加上:
$filename = $_get['filename'];