hello, I wonder if i could get some help modifying this upload script please.
At the moment I have it so a user can upload a document to the server.
What i need to be able to do now though is
1. The user selects a course from a dropdown list on the form, and then uploads the document. That dropdown list is populated from a table in my mysql database called leaders. the column names are ID, course , email.
2. When a user selects a course from the dropdown list and submits the document, i would like to send an email to the address attached to course, and in the email there will be a link to the new uploaded document on the server.
As i say the uploading of the document works at the moment but need some help modifying it with the above modifications. Could somebody help me please?.
$sess = new Session();
if($sess->getVariable("auth") != "yes")
echo("Please rename paper to delegate name. i.e joe_bloggs.pdf");
echo("<form action=\"./upload1.php\" method=\"post\" enctype=\"multipart/form-data\"/>");
echo("<label for=\"file\">Select a file:</label>
<input type=\"file\" name=\"userfile\" id=\"file\"/>
// Configuration - Options
// These will be the types of file that will pass the validation.
$allowed_filetypes = array('.doc','.txt','.pdf');
// Maximum filesize in BYTES.
$max_filesize = 2000000;
// The place the files will be uploaded to (currently /uploads/ directory).
$upload_path = './uploads/';
// Get the name of the file (including file extension).
$filename = $_FILES['userfile']['name'];
// Get the extension from the filename.
$ext = substr($filename, strpos($filename,'.'), strlen($filename)-1);
// Check if the filetype is allowed, if not DIE and inform the Delegate.
die('The file you attempted to upload is not allowed.');
// Check the filesize, if it is too large then DIE and inform the Delegate.
if(filesize($_FILES['userfile']['tmp_name']) > $max_filesize)
die('The file you attempted to upload is too large.');
// Check if we can upload to the specified path, if not DIE and inform the Delegate.
die('You cannot upload to the specified directory, please CHMOD it to 777.');
// Upload the file to your specified path.
if(move_uploaded_file($_FILES['userfile']['tmp_name'],$upload_path . $filename))
echo 'Your file upload was successful, view the file <a href="' . $upload_path . $filename . '" title="Your File">here</a>';
// It worked.
// It failed :(.
echo 'There was an error during the file upload. Please try again.';