Dear all,
I have problem in storing the image in the mySQL database. I can save it to the database, however, when i looked at it in the database, it contains"------" broken lines for the file, instead of image. Besides, there is an error msg " you cannot have more than one header, you have the header at...already"!.....I don't understand why, however, I am really hurry and anxious for the project....so really need help from you....thanks a lot!!! Also, does it matter that the uploaded image is gif or jpeg or mpeg?
Here is the script:
<body bgcolor="white">
<?php
if ($submit) {
MYSQL_CONNECT("$host","$username","$password");
mysql_select_db("binary_data");
$data = addslashes(fread(fopen($form_data, "r"), filesize($form_data)));
$result=MYSQL_QUERY("INSERT INTO binary_data (description,bin_data,filename,filesize,filetype) ".
"VALUES ('$form_description','$data','$form_data_name','$form_data_size','$form_data_type')");
$id= mysql_insert_id();
print "<p>This file has the following Database ID: <b>$id</b>";
header("Content-type: image/gif");
MYSQL_CLOSE();
} else {
// else show the form to submit new data:
?>
<!"form action" causes form to refer to itself when "submit" button is click!>
<form method="post" action="<?echo $PHP_SELF ?>" enctype="multipart/form-data">
File Description:<br>
<input type="text" name="form_description" size="40">
<INPUT TYPE="hidden" name="MAX_FILE_SIZE" value="1000000">
<br>File to upload/store in database:<br>
<input type="file" name="form_data" size="40">
<p><input type="submit" name="submit" value="submit">
</form>
<?php
}
?>
</BODY>