Forum Moderators: coopster
I know how to make a upload form and how to process the file upload, but I don't know how to add categorizing and metadata to the files, nor how to display a list of the uploaded files, based upoen their category.
This is how far I got:
uploadform.php:
<form action="upload.php" method="post" enctype="multipart/form-data">
Choose file to upload: <input name="uploadedfile" type="file" />
<br />
File category:
<select name="select_category">
<option value="cat1">Category 1</option>
<option value="cat1_a">Category 1 -Subcategory 1</option>
<option value="cat2">Category 2</option>
<option value="cat2_a">Category 2 -Subcategory 1</option>
<option value="cat3">Category 3</option>
<option value="cat3_a">Category 3 -Subcategory1</option>
</select><br />
File info: <input type="text" name="file_info" /> <br />
<input type="submit" value="Submit data" /><br />
</form>
upload.php
$target_path = "uploads/";
$target_path = $target_path . basename( $_FILES['uploadedfile']['name']);
if(move_uploaded_file($_FILES['uploadedfile']['tmp_name'], $target_path)) {
echo "The file ". basename( $_FILES['uploadedfile']['name']).
" has been uploaded";
} else{
echo "There was an error uploading the file!";
}
But then I get no categorizing, nor any other meta info. I have not found any script on the web capable of doing this, a kind of very basic DMS just for documents, with no need of login or user control.
Anyone out there who might be better googlers than me?
To accomplish this, switch [php.net] based on the category selected in the form, and change the path that the uploaded file is copied to accordingly.
Good luck! :)