PHP upload and download file source code

Source: Internet
Author: User
Welcome to the Linux community forum and interact with 2 million technical staff to access index. php! DOCTYPEhtmlPUBLIC-W3CDTDXHTML1.0TransitionalENw3.orgTRxhtml1DTDxhtml1-transitional.dtdhtmlxmlns.w3.org1999xhtmlheadmetahttp-equivContent-Type

Welcome to the Linux community forum and interact with the 2 million technical staff> go to index. php! DOCTYPE html PUBLIC "-// W3C // dtd xhtml 1.0 Transitional // EN" "plaintext" html xmlns = ".w3.org/5o/xhtml" head meta http-equiv = "Content-Type

Welcome to the Linux community forum and interact with 2 million technicians>

Index. php

Filelist



If (is_dir ($ dir )){

If ($ dh = opendir ($ dir )){

While ($ file = readdir ($ dh ))! = False ){

If ($ file! = "." & $ File! = ""){

Echo"

}

}

Closedir ($ dh );

}

}

?>

$ Dir = 'upload /';

";
". $ File ."

Bytes ---------------------------------------------------------------------------------------

Upload_file.php

Bytes ----------------------------------------------------------------------------------------

If ($ _ FILES ["file"] ["error"]> 0)

{

Echo "Return Code:". $ _ FILES ["file"] ["error"]."
";

}

Else

{

Echo "Upload:". $ _ FILES ["file"] ["name"]."
";

Echo "Type:". $ _ FILES ["file"] ["type"]."
";

Echo "Size:". ($ _ FILES ["file"] ["size"]/1024). "Kb
";

Echo "Temp file:". $ _ FILES ["file"] ["tmp_name"]."
";

If (file_exists ("upload/". $ _ FILES ["file"] ["name"])

{

Echo $ _ FILES ["file"] ["name"]. "already exists .";

}

Else

{

Move_uploaded_file ($ _ FILES ["file"] ["tmp_name"],

"Upload/". $ _ FILES ["file"] ["name"]);

Echo "Stored in:". "upload/". $ _ FILES ["file"] ["name"];

}

}

Header ('HTTP/1.1 301 Moved Permanently ');

Header ('location: files. php ');

?>

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.