Hi
I have created a table to hold a list of images to be used in a slideshow/gallery.
My table simply needs a single field for the image.
I want to use a single image upload field for each image, not the asset manager.
If i call my field "image" i get the auto generated upload/select form but would rather just have a single choose file field.
I have used the form_fields method to change the field type to file but it doesn't seem to work as needed so I have changed my field name on the table to photo.
I can set the field type to file to get the choose file button and thats OK.
How can I use validation to check a file has been selected for upload?
I think it needs to be in a hook but can you explain which hook I need to use and return an error message that a file needs to be selected.
Many thanks.
Comments
function on_after_post($values){ if (isset($this->upload_data['image'])) { $upload_path =(isset($this->upload_data['image']['full_path'])) ? $this->upload_data['image']['full_path'] : ''; if (!empty($upload_path) AND !file_exists($upload_path)) { $this->add_error('Error uploading file'); } } return $values; }