Skip to content

Instantly share code, notes, and snippets.

@f1code
Created November 14, 2015 15:44
Show Gist options
  • Select an option

  • Save f1code/1435323fa0b5ba565041 to your computer and use it in GitHub Desktop.

Select an option

Save f1code/1435323fa0b5ba565041 to your computer and use it in GitHub Desktop.
Super simple, ugly and insecure PHP script for sharing files
<form enctype="multipart/form-data" method="POST">
<input type="file" name="upload"/>
<input type="submit" value="Submit"/>
</form>
<?php
$uploads_dir = "uploads/";
if($_SERVER['REQUEST_METHOD'] == 'POST'){
if(move_uploaded_file($_FILES['upload']['tmp_name'], $uploads_dir . basename($_FILES['upload']['name']))){
echo '<p>Upload successful</p>';
} else {
echo '<p>Upload failed</p>';
}
}
$files = scandir($uploads_dir);
echo "<ul>";
foreach($files as $f) {
if($f[0] == '.')
continue;
echo "<li><a href='$uploads_dir/$f'>$f</a></li>";
}
echo "</ul>";
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment