This project is an example of some uses of $_FILES superglobal variable.
Deployed by jlammx
- 🚀 Live: View deployment
How does the PHP file handle know some basic information like file-name, file-size, type of the file and a few attributes about the file which has been selected to be uploaded? Let’s have a look at what is playing behind the scene. $_FILES is a two-dimensional associative global array of items which are being uploaded via the HTTP POST method and holds the attributes of files such as:
Attribute | Description |
---|---|
[name] | Name of file which is uploading |
[size] | Size of the file |
[type] | Type of the file (like .pdf, .zip, .jpeg…..etc) |
[tmp_name] | A temporary address where the file is located before processing the upload request |
[error] | Types of error occurred when the file is uploading |
Now see How does the array look like??
$_FILES[input-field-name][name]
$_FILES[input-field-name][tmp_name]
$_FILES[input-field-name][size]
$_FILES[input-field-name][type]
$_FILES[input-field-name][error]
Get image properties using PHP $_FILES
PHP provides various functions and DLL to extract image properties from an image. These functions are:
- imagesx() and imagesy()
- getimagesize()
- exif_read_data()
-
Array $_FILES
Show all attributes of array $_FILES when uploading a file in the same page -
HTTP file upload variables
Show all attributes of $_FILES when uploading a file on a different page (file upload manager) -
Getting image properties
Show the data or information that are associated with an image is called as metadata of the images. For example, image type, image width, and height, attributes, created date, last modified date and etc.
Array $_FILES
HTTP file upload variables
Getting image properties
🔴 Live
Last updated at 10 Mar 2023