Heres a shortened down version of an upload script ive used in the past.
Note: I made some changes, and i didnt test, it may need some debugging.
PHP Code:
<?
$ext_list = array(".zip",".rar",".wmv",".avi",".mpg",".mpeg",".wma",".m4a",".ogg",".gif",".bmp",".jpg",".jpeg",".png",".psd",".tga",".xcf",".fla",".swf",".txt",".sql",".doc",".rtf",".xls",".pp",".dwg",".exe");
$a_name = $_FILES["a_file"]["name"]; // holds the name of the file uploaded from the client
$a_type = $_FILES["a_file"]["type"]; // holds the mimetype of the uploaded file
$a_size = $_FILES["a_file"]["size"]; // holds the size in bytes of the uploaded file
$a_tmp = $_FILES["a_file"]["tmp_name"]; // holds the name of the temporary copy of the file stored on the server
$a_error = $_FILES["a_file"]["error"]; // holds any error code resulting from the file transfer
$ext = strrchr($a_name,'.');
$filePath = $upload_dir.'/'.$a_name;
if(!is_dir($upload_dir))
{
echo 'The directory to upload the files doesn\'t exist';
}
elseif(!is_writable($upload_dir))
{
echo 'The directory to upload the files is NOT writeable';
}
elseif(file_exists($upload_dir.$a_name))
{
echo 'File Already Exists - Rename Your File';
}
elseif(!$a_name)
{
echo 'You Must Select A File To Upload';
}
elseif($size > $size_bytes)
{
echo 'File Too Large, File must be smaller then <b>$kb</b> KB';
}
elseif((!in_array($ext,$ext_list)))
{
echo 'You Cannot Upload A File With That Extension - Put It In A Zip File And Try Again';
require_once("template/upload.php");
}
elseif(!move_uploaded_file($a_tmp, $filePath))
{
$error = 'Error When Uploading The File.<br>'.$a_error;
}
else
{
// Insert Into Database
if($db_query)
{
echo "File Successfully Uploaded And Added To Database";
}
else
{
echo "Error Uploaded, But Not Added To Database - Contact An Admin";
// database error delete file
unlink($filePath);
}
}
?>
also, one the function i gave you to strip the path to the file.ext, make sure you change the '/' to a '\', i tested with a URL not a C:\ path.