(High score) why cannot this code be downloaded?

Source: Internet
Author: User
(High score) why does this code fail to achieve a high score of downloading files? why does this code fail to achieve file downloading? I have tried it in LINUX and WINDOWS. Run OB_start () in WINDOWS and the program will not run. & Lt ;? Php $ rootD: wampwwwpanjinlidownloadsouce; if (is_dir ($ root) {& nbsp; & (high score) why cannot this code be downloaded?
High score rewards:
Why can't I download files using this code? I tried it in LINUX and WINDOWS. Run OB_start () in WINDOWS and the program will not run.
$ Root = "D:/wamp/www/panjinli/downloadsouce ";
If (is_dir ($ root ))
{
$ OpenHandle = opendir ($ root );
While (false! ==( $ File = readdir ($ openHandle )))
{
If (! Is_dir ($ root. $ file ))
{
Echo "". $ root. $ file ."
";
}
}
Closedir ($ openHandle );
} Else
{
Echo "the folder does not exist ";
}

$ Do = (isset ($ _ REQUEST ['do '])? Addslashes ($ _ REQUEST ['do ']): '';
If ($ do = 'low ')
{
$ File = (isset ($ _ REQUEST ['file'])? Addslashes ($ _ REQUEST ['file']): '';
$ Path = (isset ($ _ REQUEST ['path'])? Addslashes ($ _ REQUEST ['path']): '';

OB_start ();
Function DownLoad ($ info, $ file)
{
OB_Clean ();
If (! File_exists ($ info ))
{
Exit ('Error: '. _ LINE _.', '. basename (_ FILE __).'! ');
}

$ Info = file_get_contents ($ info );

Header ('content-Transfer-Encoding: binary ');
Header ('content-Type: application/force-download; name = "'. $ file .'"');
Header ('content-Disposition: attachment; filename = '. $ file .'');
Header ('cache-control: private ');
Header ('pragma: no-cache ');
Header ('expires: 0 ');
Echo $ info;
Die ();
}
DownLoad ($ path. $ file, $ file );
}
?>

------ Solution --------------------

DownLoad ($ path. $ file, $ file );

Change
DownLoad ($ path. '/'. $ file, $ file );
------ Solution --------------------
Header ('content-Disposition: attachment; filename = '. urlencode ($ file ).'');

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.