Modified upload function to delete temporary file