I'm using a simple script for uploading files to a specific directory on my web server from within a webpage:
<?php
session_start();
if(!isset($_POST['upload'])) {
echo '
<br />25 MB file size limit
<form name="upload" enctype="multipart/form-data" method="POST" action="'.$_SERVER['REQUEST_URI'].'">
<input type="file" name="file" value="">
<br /><input type="submit" name="upload" value="Upload">
</form>
';
} else {
//
// User editable info.
//
$uploaddir = 'a01/'; // Upload directory.
$MaxFleSize = '26214400'; // Maximum File size in bytes.
//
// End User editable Info
//
$filename = $_FILES['file']['name'];
$filesize = $_FILES['file']['size'];
$tmpname_file = $_FILES['file']['tmp_name'];
$date_file = date(ymd);
if($filesize > $MaxFleSize) {
echo "File is too big! 25 MB file size limit!";
} else {
move_uploaded_file($tmpname_file, $yourdomain.$uploaddir.$date_file.$filename);
echo "File uploaded Successfully.<br />URL to your file: <a href=http://share.psythik.com/".$uploaddir.$date_file.$filename."> http://share.psythik.com/".$uploaddir.$date_file.$filename."</a><br />";
}
}
?>
It works great for what it is, but I'd like to do some extra things with it, such as:
Disallow certain file types (such as .exe, .zip, etc.)
The ability to check if the file already exists, and preventing the upload if so
Add a "Description" form. Whatever's put in that space will display under "Description" when someone browses to the directory the file was uploaded to (ex: http://share.psythik.com/a01/)
Additionally, I would like to implement some sort of scheme (whether it's done in PHP or something else) where the upload page is protected by a randomly generated password that expires after, say 5 logins or 24 hours. That way, whenever someone wants to upload a file to my server, I can generate a password for them that automatically expires so that they can't pass it off to their friends. And if the site becomes popular enough, the ability to have multiple active passwords at any given moment would be great.
Unfortunately, I hardly know a thing about PHP so I don't know how any of the above could be done (if even at all possible). Help is greatly appreciated.