Refactor upload.php.