Added error checking for file uploads.