'); fclose($h); } $scriptname = basename($_SERVER["SCRIPT_NAME"]); if (isset($_FILES['filetoupload']) && isset($_POST['password'])) { sleep(3); // Reduce brute-force attack effectiveness. if ($_POST['password']!=$PASSWORD) { print 'Wrong password.'; exit(); } $filename = $SUBDIR.'/'.basename( $_FILES['filetoupload']['name']); if (file_exists($filename)) { print 'This file already exists.'; exit(); } if(move_uploaded_file($_FILES['filetoupload']['tmp_name'], $filename)) { $serverport=''; if ($_SERVER["SERVER_PORT"]!='80') { $serverport=':'.$_SERVER["SERVER_PORT"]; } $fileurl='http://'.$_SERVER["SERVER_NAME"].$serverport.dirname($_SERVER["SCRIPT_NAME"]).'/'.$SUBDIR.'/'.basename($_FILES['filetoupload']['name']); echo 'The file/image was uploaded to '.$fileurl.''; } else { echo "There was an error uploading the file, please try again !"; } echo '

Upload another file.'; exit(); } print << File/image to upload:
Password:
Self-hosting php script by sebsauvage.net EOD; ?>