$_FILES array in PHP

Colin Brazier
Colin Brazier used Ask the Experts™
on
Hi experts,

Coming back to my little project after time away, and I found an error.

Here's the form input

 
<label class="item_label">Select file:</label>
                <input type="file" id="filFileName" name="filFileName" accept=".pdf,.doc,.docx,.txt,.xls,.xlsx" style="width:25em; color: red;" <?=$disabled;?> />
                <label for="filFileName" id="fileLabel"></label>

Open in new window


and some code from the php processing it:
$file_types_array = array('doc', 'docx', 'xls', 'xlsx', 'pdf');
			$uploaded = (is_uploaded_file($_FILES['filFileName']['tmp_name'])) ? 'Upload File Present' : 'Upload File Not Present';

Open in new window


It is complaining that filFileName is undefined.  

Notice: Undefined index: filFileName in E:\xampp\htdocs7\includes\add_edit_validation.inc.php on line 68

Am I missing something obvious here?

Thanks for reading.

  Col
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Brian TaoSenior Business Solutions Consultant
Top Expert 2014

Commented:
Does it appear when you first first load the page? or after the HTTP POST?

Author

Commented:
After the post.
Brian TaoSenior Business Solutions Consultant
Top Expert 2014

Commented:
Please paste your <form> tag.
JavaScript Best Practices

Save hours in development time and avoid common mistakes by learning the best practices to use for JavaScript.

Author

Commented:
This code
echo "<PRE>";
			print_r($_FILES);
			echo "</PRE>";
			exit();

Open in new window

shows the $_FILES array to be empty.

Maybe I wipe it out somewhere along the line?

Author

Commented:
<form name="form1" id="form1" action="" method="post">
Olaf DoschkeSoftware Developer

Commented:
Check php.inin, if file_uploads= On and if you have a sufficient max size, there are both POST and FILE size limits.

Bye,  Olaf.

Author

Commented:
This has worked before with the same files.
Olaf DoschkeSoftware Developer

Commented:
Well, you said "Coming back to my little project after time away". PHP.ini could have been changed in the meantime, couldn't it?

Bye, Olaf.

Author

Commented:
Interesting...filFileName turns up in the $_POST array:

Array
(
    [txtFileHeading] => new testuibbb
    [txtFileDescription] => test for adding
    [txtExistingFileName] => Copy of Fixtures 3-31oct2015.xlsx
   [filFileName] => 1. Council mins 27.09.15.pdf
    [radUpyesno] => 0
    [txtCategory] => newsletters
    [txtPosId] => 1
    [hdnID] => 63
    [btnSubmit] => Save
)

Author

Commented:
Well, you said "Coming back to my little project after time away". PHP.ini could have been changed in the meantime, couldn't it?

True.  I'll check it.
Olaf DoschkeSoftware Developer

Commented:
The $_POST array always contains all form elements by name. It may also help you find out the temp name, but normally that isn't the true file name anyway.

If the $_FILES array really is empty, there has to be a reason for that in settings. If not PHP.ini then look into .htaccess files.

Bye, Olaf.

Author

Commented:
file_upload is on and post_max_size is 8M.  File size is 327kb

Author

Commented:
Changed form tag to

<form name="form1" id="form1" action="" method="post" encode="multipart/form-data" >

but no difference.

I will now be away for 2 hours or so.

Cheers
Olaf DoschkeSoftware Developer

Commented:
How about trying a file name without a dot in it (aside of the one before the file extension of course)?

Bye, Olaf.
Senior Business Solutions Consultant
Top Expert 2014
Commented:
It should be enctype="multipart/form-data" and not encode!

Author

Commented:
LOL, had another issue with json_encode today, so that's where that came from.

Thanks!

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial