Jump to content

Recommended Posts

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!!!!!!

Link to comment
https://forums.phpfreaks.com/topic/238467-check-if-user-wants-to-upload-image/
Share on other sites

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>';

$_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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.