#Simple Form to select a file from computer
<form action='upload_attachment.php' method='post'enctype='multipart/form-data'>
Filename <input type='file' name='uploadedfile'></div>
<INPUT TYPE='SUBMIT' Name='Submit' Value='Submit'>
</form>
<?php
#Upload File
$rand=rand(100,9999999999);
$month = date("m");
$year = date("Y");
mkdir("docs/"."$month-$year",0755,true);
$target_path = "docs/$month-$year/";
$target_path = $target_path .$rand. "-".basename( $_FILES['uploadedfile']['name']);
$filename = $rand. "-".basename( $_FILES['uploadedfile']['name']);
if(move_uploaded_file($_FILES['uploadedfile']['tmp_name'], $target_path))
{
//script to insert filename into a database table
}
?>