Vivid Lust Posted June 5, 2011 Share Posted June 5, 2011 Hi, I have a form where it is optional to upload an file however the part of the script that checks if they have selected a file is not working, here is the line: if( isset($_FILES['groupImage'])){ The script always thinks that it is set even when no file has been selected Please help guys!! Thanks lots!!!!!! Quote Link to comment https://forums.phpfreaks.com/topic/238467-check-if-user-wants-to-upload-image/ Share on other sites More sharing options...
revraz Posted June 5, 2011 Share Posted June 5, 2011 Doesn't really help with just showing that code. Quote Link to comment https://forums.phpfreaks.com/topic/238467-check-if-user-wants-to-upload-image/#findComment-1225400 Share on other sites More sharing options...
Vivid Lust Posted June 5, 2011 Author Share Posted June 5, 2011 echo '<form enctype="multipart/form-data" name="createGroup" method="post" action="">'; echo '<strong>Group Name:</strong> <input type="text" name="groupName" class="text-input" style="width:250px;" value="'.$_POST['groupName'].'"/><br />'; echo '<strong>Target Language:</strong>'; langCountrySelect(130,'option2',$_POST['groupTargetLang'],'Lang','groupTargetLang'); echo '<br /><strong>Group Description:</strong><br /> <textarea name="groupDescription" class="textarea-input"/>'.$_POST['groupDescription'].'</textarea><br />'; echo '<br /><strong>Select New Group Image:</strong> <input size="30" name="groupImage" type="file" /><br /><br />'; echo '<input type="hidden" name="editGroupSent" />'; echo '<input type="submit" value="Edit Group!" class="button-input" style="font-size: 13px;font-weight: bold;margin: 0 35px 10px 10px;" /><script language="javaScript">document.createGroup.groupName.focus();</script>'; Quote Link to comment https://forums.phpfreaks.com/topic/238467-check-if-user-wants-to-upload-image/#findComment-1225401 Share on other sites More sharing options...
PFMaBiSmAd Posted June 5, 2011 Share Posted June 5, 2011 $_FILES['groupImage']['error'] will have a value of 4 if no file was selected. It will have a value of 0 if a file was selected and uploaded without any errors. Any other value indicates an upload error occurred. Ref: http://us.php.net/manual/en/features.file-upload.errors.php Quote Link to comment https://forums.phpfreaks.com/topic/238467-check-if-user-wants-to-upload-image/#findComment-1225429 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.