By jazzdrive3 on
I have the following code:
if ($image_file = file_save_upload('radio_image', $validators, file_directory_path())) {
$result = db_query("SELECT oid FROM {uc_radio_images} WHERE oid = %d AND aid = %d", $option_id, $attribute_id);
if (db_result($result)) {
db_query("UPDATE {uc_radio_images} SET image_path = '%s' WHERE aid = %d AND oid = %d", $image_file->filepath, $attribute_id, $option_id);
} else {
db_query("INSERT INTO {uc_radio_images} (aid, oid, image_path) VALUES(%d, %d, '%s')", $attribute_id, $option_id, $image_file->filepath);
}
drupal_set_message('Image saved.','status');
} else {
drupal_set_message('Couldn\'t save file.','error');
}
And if works great for uploading. However, the drupal error message also gets displayed if they leave the file field on the form blank (it's not a required field). But can't find how to check if the field was left empty, so I can bypass the error message.
The $form_state variable doesn't seem to have any info regarding file fields.
Any help is appreciated. Thanks!
Comments
Anyone know? I know it's
Anyone know? I know it's probably something simple, but I can't find any examples. A print_r of the $form_state['values']['radio_image'] causes the white screen of death so no go there and trying to see if something is empty or not.
It must be something simple.
It must be something simple. How do check to see if what they entered was empty in the form_submit function?
Thanks.
Havind the same problem? Does
Havind the same problem? Does anybody deals with it?
It seems I've got
It seems I've got solution: