Quick Uploading & Sharing Script
Introduction
Implementation
Conclusion
Introduction
This is the unimproved version of a mad quick uploads PHP script that was whipped together for quick file-sharing between some mad crazy individuals.
The improved version has: password-protection, HTTPS support, file-type detection, auto-generated preview thumbnails for both images and text files, as well as a million other things.
The improved version has: password-protection, HTTPS support, file-type detection, auto-generated preview thumbnails for both images and text files, as well as a million other things.
Implementation
uploads.php
if ($_FILES["img"] != "") {
if ($_FILES["img"]["error"] > 0) {
echo "Return Code: " . $_FILES["img"]["error"] . "<br />";
} else {
move_uploaded_file($_FILES["img"]["tmp_name"], $_FILES["img"]["name"]);
}
}
if ($handle = opendir('.')) {
while (false !== ($file = readdir($handle))) {
if ($file != "." && $file != ".." && $file != "index.php") {
echo '<a href="' . $file . '">' . $file . '</a><br />';
}
}
closedir($handle);
}
echo '<form action="?" method="post" enctype="multipart/form-data">
<input type="file" name="img" id="img">
<br />
<input type="submit" name="login" value="upload">
</form>';
Conclusion
Only thing to keep in mind - make sure whatever your server's www user/group is, that the directory that the files would be uploaded to are properly set, otherwise files cannot be uploaded(or, as a bad idea, if you wanna cheat, chmod 0777).
0.0057520866394043 µs