Hi, I have the following error when I try to upload an image to mysql dB.(all of the other inserts work fine.. just not the data for the image)
Warning: fopen("", "r") - Success in /var/www/html/sbuniforms.com/admin/style3_insert.php on line 13
Warning: fread(): supplied argument is not a valid File-Handle resource in /var/www/html/sbuniforms.com/admin/style3_insert.php on line 13
here is the execute script:
<?php
//Connects to the SERVER and the DATABASE
include("dBconnect.inc");
//INSERT CODE
$data = addslashes(fread(fopen($_FILES['uploadfile']['tmp_name'], "r"), $_FILES['uploadfile']['size']));
$sql = "INSERT INTO styles
SET vendor_id='".$_POST['vendor_id']."',
style_code='".$_POST['style_code']."',
style_desc='".$_POST['style_desc']."',
style_para='".$_POST['style_para']."',
material_id='".$_POST['material_id']."',
subtype_id='".$_POST['subtype_id']."',
gender_id='".$_POST['gender_id']."',
web='".$_POST['web']."',
filename='".$_FILES['uploadfile']['name']."',
mimetype='".$_FILES['uploadfile']['type']."',
filedata = '".$data."'";
if (@mysql_query($sql)) {
echo( "<p>The style has been added</p>");
}
else {
echo("<p>Error adding the style.</p>");
}
?>
AND here is the form from the previous page
echo "<form action=\"style3_insert.php\" enctype=\"multipart/form-data\" method=\"post\">";
//Get image file
echo "<tr>";
echo "<td> </td>";
echo "<td>Image:</td>";
echo "<td><input type=\"file\" name=\"uploadfile\" /></td>";
echo "</tr>";