Parameter transfer to view problem
This post was last edited by yyszj0911 on 2011-11-24 14:43:05
The code is as follows (cannot pass to the view page), but with the preset $file= "/var/www/test11.txt", then you can pass it to what's going on.
Controller
function Indexaction ()
{
$file _dir = @$_post["dir"]; File path is current directory
$file _name = @$_post["file_name"]; Filename
$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 ';}
------Solution--------------------
How is the value post coming?
------Solution--------------------
Preset $file = "/var/www/test11.txt"; Obviously the absolute path, which naturally has no problem
$file = $file _dir. $file _name;
If it's an absolute path, it should be no problem.
If it is a relative path, it depends on whether it is correct. At least to know who he is relative to.