PHP;">
query("INSERT INTO uploads SET name=?,original_name=?,mime_type=?", array(basename($uploadfile,basename($_FILES['userfile']['name']),$_FILES['userfile']['type']));
if(PEAR::isError($res)) {
unlink($uploadfile);
die "Error saving data to the database. The file was not uploaded";
}
$id = $db->getOne('SELECT LAST_INSERT_ID() FROM uploads');
echo "File is valid,and was successfully uploaded. You can view it PHP?id=$id\">here\n";
} else {
echo "File uploading Failed.\n";
}
?>
PHP;">
getRow('SELECT name,mime_type FROM uploads WHERE id=?',array($id),DB_FETCHMODE_ASSOC);
if(PEAR::isError($file)) {
die("Error fetching data from the database");
}
if(is_null($file) || count($file)==0) {
die("File not found");
}
header("Content-Type: " . $file['mime_type']);
readfile($uploaddir.$file['name']);
?>