Parameter transfer to view related issues

Source: Internet
Author: User
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.
  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.