Avatar of Colin Brazier
Colin Brazier
Flag for United Kingdom of Great Britain and Northern Ireland asked on

$_FILES array in PHP

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
PHPWeb Development

Avatar of undefined
Last Comment
Colin Brazier

8/22/2022 - Mon
Brian Tao

Does it appear when you first first load the page? or after the HTTP POST?
Colin Brazier

ASKER
After the post.
Brian Tao

Please paste your <form> tag.
I started with Experts Exchange in 2004 and it's been a mainstay of my professional computing life since. It helped me launch a career as a programmer / Oracle data analyst
William Peck
Colin Brazier

ASKER
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?
Colin Brazier

ASKER
<form name="form1" id="form1" action="" method="post">
Olaf Doschke

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.
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
Colin Brazier

ASKER
This has worked before with the same files.
Olaf Doschke

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.
Colin Brazier

ASKER
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
)
This is the best money I have ever spent. I cannot not tell you how many times these folks have saved my bacon. I learn so much from the contributors.
rwheeler23
Colin Brazier

ASKER
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 Doschke

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.
Colin Brazier

ASKER
file_upload is on and post_max_size is 8M.  File size is 327kb
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
Colin Brazier

ASKER
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 Doschke

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

Bye, Olaf.
ASKER CERTIFIED SOLUTION
Brian Tao

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
Colin Brazier

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

Thanks!
All of life is about relationships, and EE has made a viirtual community a real community. It lifts everyone's boat
William Peck