WP-Mix

A fresh mix of code snippets and tutorials

Structure of $_FILES array

Working with USP Pro involves a lot of $_FILES manipulation. I tend to forget how the array is structured, so I’m posting it here for ez reference.

$_FILES array

Here is the structure of a typical $_FILES array:

array(5) { 
	["name"]=> array(1) { 
		[0]=> string(21) "example.jpg" 
	} 
	["type"]=> array(1) { 
		[0]=> string(10) "image/jpeg" 
	} 
	["tmp_name"]=> array(1) { 
		[0]=> string(14) "/tmp/php12345" 
	} 
	["error"]=> array(1) { 
		[0]=> int(0) 
	} 
	["size"]=> array(1) { 
		[0]=> int(94061) 
	} 
}

Bonus: getimagesize array

Often used in conjuction with $_FILES, PHP’s getimagesize function reveals a wealth of file data. Here is the general structure of its array:

array(7) {
	[0]=> int(960) 
	[1]=> int(250) 
	[2]=> int(2) 
	[3]=> string(24) "width="960" height="250"" 
	["bits"]=> int(8) 
	["channels"]=> int(3) 
	["mime"]=> string(10) "image/jpeg" 
}

That’s all folks.

★ Pro Tip:

USP ProSAC Pro