I'm trying to upload images into and view images from an SQL database. I've used the tutorials here and on other sites w/ the exact same results. Basically I can't load my images into the database. Here's the code stripped down to it's basics:
Page 1: Form for entering data
<html>
<head><title>Store binary data into SQL Database</title></head>
<body>
<form method="post" action="images2.php" enctype="multipart/form-data">
<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>
</body>
</html>
Page 2: images2.php , file for processing data
<html>
<head><title>Store binary data into SQL Database</title></head>
<body>
<?php
// code that will be executed if the form has been submitted:
MYSQL_CONNECT("localhost","root","spa1spa1");
mysql_select_db("SPA");
$data = addslashes(fread(fopen($form_data, "r"), filesize($form_data)));
$result=MYSQL_QUERY("INSERT INTO images (binary_junk,filename,filesize,filetype) VALUES ('$data','$form_data_name','$form_data_size','$form_data_type')");
MYSQL_CLOSE();
print $_POST['form_data_name'];
?>
You did it.
</body>
</html>
Problem: Seems I'm attaching to the database just fine, but it's giving me a bunch of undefinied variable errors:
Notice: Undefined variable: form_data in c:\inetpub\wwwroot\images2.php on line 17
Notice: Undefined variable: form_data in c:\inetpub\wwwroot\images2.php on line 17
Warning: fread(): supplied argument is not a valid stream resource in c:\inetpub\wwwroot\images2.php on line 17
etc.
You can see that I also included print $Post_['form_data_name']; just to see if it came through at all, which it didn't. The page is available at http://spa.ward.american.edu/images.php .
Thanks so much,
J