Several points worth noting when uploading files in PHP:
1. In the form form, set the method attribute to post and the enctype attribute to multipart/form-data;
2. Upload file size limit
1) The upload_max_filesize in the PHP configuration file (PHP3 is php3.ini, PHP4 is php.ini) is used to limit the maximum upload file size that PHP can handle, calculated in bytes, the default is 2097152=2*1024*1024 Bytes (2 megabytes), please note that you must restart Apache after modifying the file, otherwise it will not take effect;
2) You can add a hidden type input box to the form, named MAX_FILE_SIZE, and its The value is the maximum number of bytes allowed to be uploaded by the client. Of course, this value cannot exceed the upload_max_filesize in the PHP configuration file (PHP3 is php3.ini, PHP4 is php.ini). Note that this input box must be placed in all file types. in front of the input box, otherwise it will be invalid;
3. The uploaded file temporary storage directory
upload_tmp_dir in the PHP configuration file (PHP3 is php3.ini, PHP4 is php.ini) is used to set
The uploaded file is temporarily stored in the directory. Note that the account running Apache must have read and write permissions on this directory.
At the same time, you must restart Apache after making the modification, otherwise it will not take effect;
4. After the PHP program is finished running , the system automatically deletes the temporary files of the uploaded files on the server, so if you want to process the uploaded files (such as copying to another directory or putting the file contents into the database), you must do it in this PHP program.