Created
November 14, 2015 15:44
-
-
Save f1code/1435323fa0b5ba565041 to your computer and use it in GitHub Desktop.
Super simple, ugly and insecure PHP script for sharing files
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <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