Still no good
I forgot to mention that I'd already tried it that way but still had the same error. However if I add the folder info before it then it works BUT this info is then stored in the database as folder/folder/filename.jpg
Naturally this won't then work when the user comes to change details and leaves the field blank a second time.
I've included the file for you to look at again.