there seem to be a lot of people asking this question and not getting an answer. is there an issue with checking if a file upload part of a form has been filled in or not? is this because its a global variable and is allways set?
the problem im having is checking if a file input ytpe has been filled in or not.
the code below shows various examples of checking to see if the file field is filled in by the user or not.
they all fail to spot when its been filled in:
<?php
if (isset($_POST['add']))
{
//if (!isset($_POST['pic'])) { echo"pic not filled in";}else{echo"pic filled in";}
if (!isset($_POST['pic'])) { echo"pic not filled in";}
if (isset($_POST['pic'])) { echo"pic filled in";}//end of check to see if picture has been filled in
//if (!isset($_POST['userfile[]'])) { echo"pic not filled in";}
//if (isset($_POST['userfile[]'])) { echo"pic filled in";}//end of check to see if picture has been filled in
//$pictureName = $_REQUEST['pic'];
//if ($pictureName == ''){echo"pic is blank";}
//else{echo"pic is NOT blank";}
//if ($_POST['pic'] == ""){echo"pic is blank";}
//else {echo"pic is NOT blank";}
}
else
{
/////////render form
?>
<form enctype="multipart/form-data" action="" method="post" id="save"><fieldset>
<input type="text" name="fileName" id="fileName" value=""/>
<input type="file" name="userfile[]" id="pic" />
<input name="add" id="save_button" type="submit" value="Update"/>
</fieldset></form>
<?php
}
?>