In this case, why cannot I download files?

Source: Internet
Author: User
In this case, why cannot I download files? $ Root = "D:/wamp/www/New Folder /";
If (is_dir ($ root ))
{
$ OpenHandle = opendir ($ root );
While (false! ==( $ File = readdir ($ openHandle )))
{
If (! Is_dir ($ root. $ file ))
{
Echo "". $ file ."
";
Echo "$ root $ file
";
}
}
Closedir ($ openHandle );
}
Else
{
Echo "the folder does not exist ";
}
?>
Why can't this code be used to download files? the Sogou browser has tried IE.


Reply to discussion (solution)

Download with header

Can I download a test program with the header?

Already ?? You? Okay.

 ";}} Closedir ($ openHandle);} else {echo" the folder does not exist. ";}$ do = (isset ($ _ REQUEST ['do '])? Addslashes ($ _ REQUEST ['do ']): ''; if ($ do = 'drop ') {$ 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 );}

Already ?? You? Okay.

 ";}} Closedir ($ openHandle);} else {echo" the folder does not exist. ";}$ do = (isset ($ _ REQUEST ['do '])? Addslashes ($ _ REQUEST ['do ']): ''; if ($ do = 'drop ') {$ 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 );}
No. I just downloaded the php file.

Already ?? You? Okay.

 ";}} Closedir ($ openHandle);} else {echo" the folder does not exist. ";}$ do = (isset ($ _ REQUEST ['do '])? Addslashes ($ _ REQUEST ['do ']): ''; if ($ do = 'drop ') {$ 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 );}

Error code: 27

File_put_contents ('Download/excel.csv ', $ str );
Header ("location: download/excel.csv"); // let the computer automatically pop up the download dialog box

File_put_contents ('Download/excel.csv ', $ str );
Header ("location: download/excel.csv"); // let the computer automatically pop up the download dialog box where to add

Already ?? You? Okay.

 ";}} Closedir ($ openHandle);} else {echo" the folder does not exist. ";}$ do = (isset ($ _ REQUEST ['do '])? Addslashes ($ _ REQUEST ['do ']): ''; if ($ do = 'drop ') {$ 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 );}

If ($ do = 'low'), this judgment is always unsuccessful. what should I do if the code in the braces cannot be executed?

Already ?? You? Okay.

 ";}} Closedir ($ openHandle);} else {echo" the folder does not exist. ";}$ do = (isset ($ _ REQUEST ['do '])? Addslashes ($ _ REQUEST ['do ']): ''; if ($ do = 'drop ') {$ 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 );}

Is there a problem with your statement? "echo" ". $ root. $ file ."
";" How to change it?

Href = '? Do to href = 'A. php? Do

A. is php yours? Php file name


Already ?? You? Okay.

 ";}} Closedir ($ openHandle);} else {echo" the folder does not exist. ";}$ do = (isset ($ _ REQUEST ['do '])? Addslashes ($ _ REQUEST ['do ']): ''; if ($ do = 'drop ') {$ 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 );}

Error code: 27 ?? What is the description ????? Outbound ?? Take a look


Already ?? You? Okay.

 ";}} Closedir ($ openHandle);} else {echo" the folder does not exist. ";}$ do = (isset ($ _ REQUEST ['do '])? Addslashes ($ _ REQUEST ['do ']): ''; if ($ do = 'drop ') {$ 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 );}
No. I just downloaded the php file.
Me? ?? Method regardless of file? Can all be lower ?, As long? File? ? Limited to get down ?, So you want to list it? ? Should php be excluded? Type.

My file name is "download. php", but it still doesn't work. you can check it out for me.
$ 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 );
}
?>




Already ?? You? Okay.

 ";}} Closedir ($ openHandle);} else {echo" the folder does not exist. ";}$ do = (isset ($ _ REQUEST ['do '])? Addslashes ($ _ REQUEST ['do ']): ''; if ($ do = 'drop ') {$ 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 );}
No. I just downloaded the php file.
Me? ?? Method regardless of file? Can all be lower ?, As long? File? ? Limited to get down ?, So you want to list it? ? Should php be excluded? Type.



Already ?? You? Okay.

 ";}} Closedir ($ openHandle);} else {echo" the folder does not exist. ";}$ do = (isset ($ _ REQUEST ['do '])? Addslashes ($ _ REQUEST ['do ']): ''; if ($ do = 'drop ') {$ 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 );}
No. I just downloaded the php file.
Me? ?? Method regardless of file? Can all be lower ?, As long? File? ? Limited to get down ?, So you want to list it? ? Should php be excluded? Type.
Are you tested in LINUX? files downloaded from LINUX cannot be successfully executed on WINDOWS. some messy content will be written for support.




Already ?? You? Okay.

 ";}} Closedir ($ openHandle);} else {echo" the folder does not exist. ";}$ do = (isset ($ _ REQUEST ['do '])? Addslashes ($ _ REQUEST ['do ']): ''; if ($ do = 'drop ') {$ 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 );}
No. I just downloaded the php file.
Me? ?? Method regardless of file? Can all be lower ?, As long? File? ? Limited to get down ?, So you want to list it? ? Should php be excluded? Type.
Did you test it in LINUX? if I put it on WINDOWS, the files downloaded in LINUX cannot be successfully executed. some messy content will be written for support. am I in windows and linux ???, Everything is normal

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.