PHP file uploadThe principle is simply analyzed. Friends who learn PHP can refer to it. It is indeed much simpler than asp.
//Form uploads can only use the multipart/form-data encoding format
$_FILES systemFunction;
$_FILES['myFile']['name'] file Name
$_FILES['myFile']['type']The type of file, restricted by the server
image/**
image/x-png
application/x-zip-compressed
$_FILES['myFile']['size']Upload file size
$_FILES['myFile']['tmp_name']Save the temporary file name after uploading to the service
$_FILES['myFile'][ 'error'] Error code;
0 Success 1 Exceeds the php.ini size 2 Exceeds the value specified by the MAX_FILE_SIZE option
3 Only partially uploaded 5 The uploaded file size is 0
move_uploaded_file(temporary file, target location and file name);
Function to move the file to the target location after uploading
is_uploaded_file(MIME);
Function to determine the uploaded MIME type of the file
The code is as follows:
The above is the detailed content of A brief introduction to the principle of php file upload. For more information, please follow other related articles on the PHP Chinese website!