Added error checking for the file upload