Well, that script is kind of deprecated. By that I mean you can't reference POSTed variables by using $variable. You have to explicitly reference them as: $_POST['name_value'].
Here is a script that should help you:
<?php
// Let's define some constants:
$allowed_ext = array('.gif', '.jpg', '.jpeg', '.png', '.bmp', '.tif',
'.htm', '.html', '.txt', '.doc', '.rtf', '.pdf');
// Feel free to add what extensions you need
$limit_ext = TRUE;
$max_size = 1024 * 1024 * 5; // 5 MB max upload. Bytes * KB * MB
// Suggested that you change it!!
$up_dir = $_SERVER['DOCUMENT_ROOT'].'/FOLDER/'; // Change to your needs,
// KEEP TRAILING SLASH!!
$up_link = 'http://'.$_SERVER['HTTP_HOST'].'/FOLDER/'; // Same as above
$db_host = 'localhost'; // Database host (normally localhost);
$db_user = 'root'; // User to connect as
$db_pass = 'password'; // Password for user
$db_table = 'database'; // Database to use
$table = 'tablename'; // Table to use
//---------------------------------------------------------------------\\
if(!is_uploaded_file($_FILES['file']['tmp_name']))
{
// File not uploaded, show default form!!
$show = 1;
}
elseif(is_uploaded_file($_FILES['file']['tmp_name']))
{
// File is there, now we'll work with it
$show = 2;
}
else
{
// Possible hack attempt, who knows.
// If it doesn't fit the first two, it defaults here
$show = 1;
}
/*
Now we're going to switch the $show variable. If it's equivalent to 1,
we want to show the upload form. If it's equivalent to 2, we want to
work with the uploaded file.
*/
switch($show)
{
case 1:
// We just want to show a form here. Simple and quick.
?>
<html>
<head>
<title>Your Page Title</title>
</head>
<body>
<p style="float: left;">
<form action="" method="post" enctype="multipart/form-data" style="float: left;">
Your Name: <input type="text" name="creator"><br>
Description: <input type="text" name="descrip"><br><br>
File Name: <input type="text" name="name"> * Don't include the extension!!<br>
File to Upload: <input type="file" name="file" size="35"><br>
<input type="submit" value="Upload the File">
</form>
</p>
</body>
</html>
<?php
break;
case 2:
$tmpname = $_FILES['file']['tmp_name'];
$creator = $_POST['creator'];
$descrip = $_POST['descrip'];
$ext = strrchr($tmpname,'.');
$new_name = $_POST['name'].$ext;
$download = $up_link.$new_name;
if(($limit_ext === TRUE) && (!in_array($ext, $allowed_ext)))
{
echo 'That is not an allowed extension!!';
exit();
}
if(file_exists($up_dir.$new_name))
{
echo "File ($new_name) already exists in $up_dir.";
exit();
}
else
{
if(move_uploaded_file($tmpname, $up_dir.$new_name))
{
$query = "INSERT INTO `$table` (Name, Description, Download, Creator)
VALUES ('$name', '$descrip', '$download', '$creator')";
$result = @mysql_query($result);
if(!$result)
{
echo 'Query Error!!<br>'.mysql_errno().'<br>'.mysql_error();
exit();
}
else
{
echo 'Inserted into database!!';
echo '<br><a href="'.$download.'">Download Now</a>';
}
}
else
{
echo 'Error moving file. Sorry.';
exit();
}
}
break;
}
?>
That should start you on your way.
~Brett