3. PHP file upload and resource commands
File_uploads (boolean)
Whether to enable the http post file upload function
Max_execution_time (integer)
Maximum PHP script execution time
Memory_limit (integer) Unit: M
Maximum memory for running PHP scripts
Upload_max_filesize (integer) Unit: M
PHP maximum size of uploaded files
Upload_tmp_dir (string)
Temporary location of uploaded file storage
Post_max_size (integer) Unit: M
Maximum size of http post data
4. $ _ FILES Array
$ _ FILES ['userfile'] [size]
Obtains the number of bytes of the uploaded file.
$ _ FILES ['userfile'] ['type']
Obtain the MIME type of the uploaded file. Each MIME type is composed of the primary and child types separated "/".
$ _ FILES ['userfile'] ['error']
Get the error code of the uploaded file. Value 0: no error. The file is successfully uploaded. Value 1: the size of the uploaded file exceeds the value specified by the upload_max_filesize option in the PHP configuration file. Value 2: the size of the uploaded file exceeds the value specified by MAX_FILE_SIZE in the HTML form. 3: indicates that the file is only partially uploaded; 4: indicates that no file is uploaded.
$ _ FILES ['userfile'] ['name']
Get the original name of the uploaded file, including the extension
$ _ FILES ['userfile'] ['tmp _ name']
Obtain the temporary location name of the uploaded file, which is the file name specified in the temporary directory.
5. File upload function
Is_upload_file
Checks whether the specified file is uploaded through http post.
Bool is_upload_file (string $ filename)
Move_upload_file
Move the uploaded file to a new location
Bool move_upload_file (string $ filename, string $ destination)
Note: After a file is uploaded, it is first stored in the temporary directory of the server. You can use this function to move the uploaded file to a new location. Compared with copy () and move, it can detect and ensure that the file specified by the first filename parameter is a legally uploaded file.
6. Error Message description
UPLOAD_ERR_ OK {value = 0}
UPLOAD_ERR_INI_SIZE {value = 1}
UPLOAD_ERR_FORM_SIZE {value = 2}
UPLOAD_ERR_PARTIAL {value = 3}
UPLOAD_ERR_NO_FILE {value = 4}
UPLOAD_ERR_NO_TMP_DIR {value = 6}
UPLOAD_ERR_CANT_WRITE {value = 7}
<?phpprint_r($_FILES);?>