欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  后端开发

参数传送到视图有关问题

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

view:
$file = $this->downfile;

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



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

$file=$file_dir.$file_name;
如果也是绝对路径的话应该是没有问题的
如果是相对路径的话,那就要看是否正确了。至少要知道他相对于谁
参数传送到视图有关问题

声明:本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn核实处理。

相关文章

相关视频


网友评论

文明上网理性发言,请遵守 新闻评论服务协议

我要评论
  • 参数传送到视图有关问题
  • 专题推荐