Home  >  Article  >  Backend Development  >  参数传送到视图有关问题

参数传送到视图有关问题

WBOY
WBOYOriginal
2016-06-13 12:59:52719browse

参数传送到视图问题

本帖最后由 yyszj0911 于 2011-11-24 14:43:05 编辑 代码如下(传不到视图页) ,但是用预设的$file="/var/www/test11.txt";的话就能够传的到 这是怎么回事阿
controller:
function indexAction()<br />
    {<br />
		$file_dir = @$_POST["dir"]; //文件路径为当前目录	<br />
		$file_name = @$_POST["file_name"]; //文件名<br />
		$file=$file_dir.$file_name;<br />
		//$file="/var/www/test11.txt";<br />
		$this->view->downfile = $file;<br />
		echo $this->view->render('download/download.phtml');<br />
    }<br />

view:
$file = $this->downfile;<br />
<br />
if (file_exists($file)) {<br />
    header('Content-Description: File Transfer');<br />
    header('Content-Type: application/octet-stream');<br />
    header('Content-Disposition: attachment; filename='.basename($file));<br />
    header('Content-Transfer-Encoding: binary');<br />
    header('Expires: 0');<br />
    header('Cache-Control: must-revalidate, post-check=0, pre-check=0');<br />
    header('Pragma: public');<br />
    header('Content-Length: ' . filesize($file));<br />
    ob_clean();<br />
    flush();<br />
    readfile($file);<br />
    exit;<br />
}<br />
//$file = $this->downfile;<br />
else{echo $file.'ssa';}



------解决方案--------------------
值是怎么post过来的呢?
------解决方案--------------------
预设的 $file="/var/www/test11.txt"; 显然是绝对路径,这自然没有问题

 $file=$file_dir.$file_name; 
如果也是绝对路径的话应该是没有问题的
如果是相对路径的话,那就要看是否正确了。至少要知道他相对于谁
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn