Home > Backend Development > PHP Tutorial > PHP file upload function implementation code_PHP tutorial

PHP file upload function implementation code_PHP tutorial

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-07-21 15:45:11
Original
831 people have browsed it

Personally, I think the idea of ​​uploading and downloading PHP files is almost the same. That is, there is an extra header statement in the code
The following is the detailed code. For reference only.
Entry file

Copy code The code is as follows:



enctype="multipart/form-data">

" />






php write Processing files
if( empty($_GET['FileName'])){
echo'<script> alert("Illegal connection!"); location.replace (" ./fileload.html") </script>'; exit();
}
$file_name=$_GET['FileName'];//Get the file to be downloaded
if (!file_exists ($file_name)) { //Check if the file exists
echo "File not found";
exit;
} else {
$file = fopen( $file_name,"r"); // Open the file
// Enter the 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 I found it on the Internet, but it was not complete. After a period of debugging and modification, I finally realized the function. I was so excited that I shared it with everyone as soon as possible.

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/320348.htmlTechArticleI personally think that the idea of ​​uploading and downloading PHP files is almost the same. That is, there is an extra header statement in the code as follows It is a detailed code. For reference only. The entry file copy code is as follows...
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Issues
php data acquisition?
From 1970-01-01 08:00:00
0
0
0
PHP extension intl
From 1970-01-01 08:00:00
0
0
0
How to learn php well
From 1970-01-01 08:00:00
0
0
0
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template