Update Form with optional file upload with server behaviour
I am trying to create an update record form that has an optional file field to upload an image.
The image is verified for file size and allowed extension (jpg, png etc).
I also need to automatically delete the original image if there is one and replace it with a new image if the user wants to.
The validation works, and I added 2 delete behaviours for the image, one for the full size image and one for the thumbnail. But I am probably trying to do the above in the wrong way.
My problem is that if an image is not uploaded, the form returns the server validation saying "You can only upload jpeg, jpg, gif or png files."
If an image already exists I still get the validation error message.
Attached is the page in question.
Any help will be greatly appreciated.