(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 ).'');