I am trying to get a simple file upload working... but no luck. The error I recieve is my subject line. Any ideas where I am making a wrong turn?
The table is called filestore with...
filestore_id as int, primary
filename as varchar
mimetype as varchar
description as varchar
filedata as medium blob
picture.php
<?PHP
//Connects to the SERVER and the DATABASE
include("dBconnect.inc");
?>
<form action="picture2.php" method="post" enctype="multipart/form-data">
<p>Upload File<br />
<input type="file" name="uploadfile" /></p>
<p>File Description:<br />
<input type="text" name="desc" maxlength="255" /></p>
<p><input type="submit" name="go" value="Upload" /></p>
</form>
picture2.php
<?PHP
//Connects to the SERVER and the DATABASE
include("dBconnect.inc");
//Collects data, processes, and INSERTS
$uploadfile = $_POST["uploadfile"];
$desc = $_POST["desc"];
$tempfile = fopen($uploadfile,"rb");
$filedata = fread($tempfile,filesize($uploadfile));
$filedata = addslashes($filedata);
$sql = "INSERT INTO filestore SET
filename = $uploadfile_name,
mimetype = $uploadfile_type,
description = $desc,
filedata = $filedata";
if (mysql_query($sql)) {
echo "<p>The file has been added</p>";
}
else {
echo "<p>Error adding the file.</p>";
}
?>