Skip to content

jlammx/php_files

Repository files navigation

PHP | $_FILES Array

This project is an example of some uses of $_FILES superglobal variable.

Deployed by jlammx


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:

  1. imagesx() and imagesy()
  2. getimagesize()
  3. exif_read_data()

👨‍💻 Examples

  • 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.

📸 Screenshots

Array $_FILES

Array $_FILES Array $_FILES

HTTP file upload variables

HTTP file upload variables HTTP file upload variables

Getting image properties

Getting Image Properties Getting Image Properties

🔴 Live

Live

📈 Skills

PHP Html5 Css3


Jorge Aguirre     

Last updated at 10 Mar 2023

About

Superglobal variable $_FILES

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published