Windows XP
PHP 4.4.2
Apache 2.2
Register_Globals = Off
Safe_Mode = On
Hi All,
I am having a problem getting a file browse input field to be recognized on the next page. Let me show you...
page1.php Contains a web form with a file input to attach a file using a browse button.
<form method='POST' action='page2.php' enctype='multipart/form-data'>
<input name='uploadFile1' type='file' id=uploadFile1'>
page2.php contains a validator to check the input and perform an action based on whether or not the browse input field has been populated.
// IF THE POST CONTAINS A FILE UPLOAD, PROCESS SECTION 1 IF NOT PROCESS SECTION 2.
if (isset($_POST['uploadFile1'])) {
echo "File is attached so print this.";
}
if (!isset($_POST['uploadFile1'])) {
echo "File is NOT attached so print this.";
}
If the user uses the browse button on the form page to populate the field with a file path to a file on his pc, then I expect to see the "File is attached message". However, regardless of whether someone does or does not browse a file, the message is always that they have NOT browsed a file and the variable "uploadFile1" is effectively left unpopulated.
OUTPUT
File is NOT attached so print this.
Conversley, I thought I might be able to use the FILES variable instead of POST, but I get the exact opposite, that the browse field is populated all the time whether or not someone has browsed a file or left the browse field blank.
if (isset($_FILES['uploadFile1'])) {
echo "File is attached so print this.";
}
if (!isset($_FILES['uploadFile1'])) {
OUTPUT
File is attached so print this.
So, I am missing something. Can someone give me some direction so that I can simply identify (with register_globals = Off) whether or not an input field (input type=file) has been populated or left blank? Is this even possible? What am I missing?
Thanks.