# PHP $_FILES Variable – A Beginner Guide By | September 14, 2020 PHP$_FILES variable is often used when uploading files. In this tutorial, we will introduce it for php beginners.

## What information we can get from php $_FILES? As to example above, we can use$_FILES[‘photo’] to get these information:

 $_FILES[‘photo’][‘name’] file name testfile.txt$_FILES[‘photo’][‘type’] file mime type application/octet-stream, image/gif $_FILES[‘photo’][‘size’] file size in byte 4321$_FILES[‘photo’][‘tmp_name’] the path of file that is saved in server temporarily, this value can be set by upload_tmp_dir in php.ini such as: /tmp/php6wHXmC \$_FILES[‘photo’][‘error’] the error code UPLOAD_ERR_OK (0) upload successfully UPLOAD_ERR_INI_SIZE (1) the file size if bigger than upload_max_filesize in php.ini UPLOAD_ERR_FORM_SIZE (2) the file size is larger than maximum size in html form UPLOAD_ERR_PARTIAL (3) a part of file has been uploaded UPLOAD_ERR_NO_FILE (4) no file uploaded
Category: PHP