brianstorm Posted October 8, 2007 Share Posted October 8, 2007 Hi, I am attempting to create a php / mysql data entry page which also has an image upload function. It all works fine apart from where I have no image to upload (which may be the case).... I have a form of the following type method="POST" enctype="multipart/form-data">'; with this item in the form echo '<input type="file" name="image">'; which is processed on another page... so I am looking for something along the lines of this if(isset($_POST['image'])) { run my image upload code } but this doesn't seem to work.... all the image upload code I have seen tests for the value of the submit button, which in this case will always exist... I really don't want to have more than one form if it can be avoided... if anyone can help point me in the right dircetion it would be greatly apperecciated.... many thanks brian.... Link to comment https://forums.phpfreaks.com/topic/72312-solved-how-to-test-for-image-upload-presence-where-there-are-several-form-items/ Share on other sites More sharing options...
Norsk.Firefox Posted October 8, 2007 Share Posted October 8, 2007 if($_FILES['image']) // Do the upload thing else // Jump over the upload Link to comment https://forums.phpfreaks.com/topic/72312-solved-how-to-test-for-image-upload-presence-where-there-are-several-form-items/#findComment-364606 Share on other sites More sharing options...
brianstorm Posted October 8, 2007 Author Share Posted October 8, 2007 thanks for that... its still not working though... i guess cos the value image exists in the form whether an image is uploaded or not? any further pointers much apprecciated... Link to comment https://forums.phpfreaks.com/topic/72312-solved-how-to-test-for-image-upload-presence-where-there-are-several-form-items/#findComment-364643 Share on other sites More sharing options...
brianstorm Posted October 8, 2007 Author Share Posted October 8, 2007 ah, solved it... thansk again for the $FILES.... i tested for a 0 file size using if($_FILES['image']['size'] > 0) { execute code here} Link to comment https://forums.phpfreaks.com/topic/72312-solved-how-to-test-for-image-upload-presence-where-there-are-several-form-items/#findComment-364722 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.