Forum Moderators: coopster

Message Too Old, No Replies

Upload file with metadata and retrieve it

file upload, metadata, category

         

Awful newbie

8:31 pm on Apr 3, 2007 (gmt 0)

10+ Year Member



Hello again. I just wonder if anyone have a hint in order to solve this question: I am in need of a script where I can upload files, categorize them, and hopefully add some metadata to them, and later display a list of categorized files (for inclusion in other pages, depending on which category the files are in).

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?

eelixduppy

9:16 pm on Apr 3, 2007 (gmt 0)



The best way to categorize your files is to put them into their own separate directories. This way, everything will be nice and organized :)

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! :)