Jump to content

Check if user wants to upload image


Vivid Lust

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.