fixes #2300 Form redirect issue with file or image uploads

Fixed the issue and committed code for review, please check it.