Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Beginners PHP Question: What the difference between $_POST and $_FILES?

Tags:

php

Beginners PHP Question: What the difference between $_POST and $_FILES?

PHP.net says:

$_POST is an associative array of variables passed to the current script via the HTTP POST method

$_FILES is an associative array of items uploaded to the current script via the HTTP POST method

Could anyone explain what this means in practical terms?

like image 653
christina Avatar asked Dec 12 '22 13:12

christina


1 Answers

Both $_POST and $_FILES are so called in php "superglobals". They are predefined variables(arrays), which means they are available in all scopes throughout a script. There is no need to declare them to access them within functions or methods.

$_POST contains all the data from forms (except files)

$_FILES contains all files sent to server via forms (only from <input type="file" />)

like image 106
Bakudan Avatar answered Jan 13 '23 10:01

Bakudan