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...