User Tools

Site Tools


online_experiments

This is an old revision of the document!


');

  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 <a href="'.$fileurl.'">'.$fileurl.'</a>';
  } 
  else { echo "There was an error uploading the file, please try again !"; }
  echo '<br><br><a href="'.$scriptname.'">Upload another file.</a>';
  exit();

} print «<EOD <form method=“post” action=“$scriptname” enctype=“multipart/form-data”>

  File/image to upload: <input type="file" name="filetoupload" size="60">
  <input type="hidden" name="MAX_FILE_SIZE" value="256000000"><br>
  Password: <input type="password" name="password"><br>
  <input type="submit" value="Send">   

</form> <small>Self-hosting php script by <a href=“http://sebsauvage.net/wiki/doku.php?id=php:filehosting”>sebsauvage.net</a></small> EOD; ?> </body> </html>

online_experiments.1565954897.txt.gz · Last modified: 2019/08/16 13:28 by admin