PHP file upload
File Upload Overview
The file upload function is a function often used in online life. File upload can be easily achieved using PHP. The specific process is as follows:
Select file in form-> Check file size and type-> Generate temporary file-> Move temporary file to file storage directory-> ; Record file information for easier management.
In the file upload function, the following issues need to be considered:
1. Limit the size of the uploaded file
2. Limit the type of the uploaded file
3. Only allow trusted users to upload files and prevent remote submission
4. Server-side file storage directory
5. Management of files after uploading
Through PHP , you can upload files to the server.
The examples in this chapter are completed under the test project. The directory structure is:
test
|-----upload #Directory for file upload
|-----form.html #Form file
|-----upload_file.php #php upload code
Source code download
Create a file upload form
It is very useful to allow users to upload files from a form.
Please look at the HTML form for uploading files below:
php中文网(php.cn)
Save the above code into the form.html file.
Some notes about the above HTML form are listed below:
The enctype attribute of the