PHP Undefined index - Occuring when the variable has a value in it
- by Adam
I have the following code that is being used to successfully upload images:
$fileName = $_FILES['file']['name'];
$fileSize = $_FILES['file']['size'];
$fileType = $_FILES['file']['type'];
$fileTmp = $_FILES['file']['tmp_name'];
list($origWidth, $origHeight) = getimagesize($fileTmp);
The catch is I'm getting an 'Undefined index' on each line.
I have print_r($_FILES) just before this code and each array variable exists and I've echo out varibles like $fileName and can see each has a value.
Also I have put this before this code block and it makes no difference:
$fileName = $fileSize = $fileType = $fileTmp = '';
Any suggestions how I can ensure these variables are defined?
thankyou