add error logging to upload image