PHP file upload function implementation code _ PHP Tutorial

Source: Internet
Author: User
Php file upload function implementation code. I personally think the idea of uploading and downloading php files is similar. that is, a header statement is added to the code. The following is the detailed code. for reference only. for example, I personally think that the idea of uploading and downloading php files is the same. that is, a header statement is added to the code.
The following code is for reference only.
Portal file

The code is as follows:







Processing files written in php
If (empty ($ _ GET ['filename']) {
Echo 'script alert ("illegal connection! "); Location. replace ("./fileload.html ") script '; exit ();
}
$ File_name = $ _ GET ['filename']; // GET the object to be downloaded
If (! File_exists ($ file_name) {// check whether the file exists
Echo "file not found ";
Exit;
} Else {
$ File = fopen ($ file_name, "r"); // open the file
// Input file tag
Header ("Content-type: application/octet-stream ");
// Header ("Accept-Ranges: bytes ");
// Header ("Accept-Length:". filesize ($ file_name ));
// Header ("Content-Disposition: attachment; filename =". $ file_name );
// Output file content
Echo fread ($ file, filesize ($ file_name ));
Fclose ($ file );
Exit ();
}
?>


The above code is found on the Internet, but it is not complete. I have recorded debugging and modification for a while. finally, the function is implemented. I am so excited that I will share it with you in the first time.

The following is the detailed Code. it is for reference only. the code of the entry file is as follows...

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.