Use the preview property to store and retrieve the image previews. Fixes #2592
Fixed file upload error handling.

Thanks to Daouda Kanoute for the report.
Added imageOrientation parameter to define the orientation for resized images.