PHP Undefined index - Occuring when the variable has a value in it

Posted by Adam on Stack Overflow See other posts from Stack Overflow or by Adam
Published on 2013-06-30T04:16:16Z Indexed on 2013/06/30 4:21 UTC
Read the original article Hit count: 88

Filed under:
|
|
|

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

© Stack Overflow or respective owner

Related posts about php

Related posts about arrays