I worked all day on this, so I thought it might be useful to others.
Its adapted from Florian Dittmer's article on PHPBuilder.com:
http://phpbuilder.com/columns/florian19991014.php3

The script is for storing binary (image) data directly into a MySQL
table.  I did not have to create a separate DATABASE - just a BLOB
table.  Both types of Magic quotes are off.

My problem was that I like real lean code, and thought I could do
without things like filesize....nooooo

<html>
<body>
<form method="post" 
action="binform.html" 
enctype="multipart/form-data">
FILE DESCRIPTION:<br>
<input type="text" name="form_description">
<input type="hidden" name="max_file_size" value="750000">
<br>File to Upload/store in DB:<br>
<input type="file" name="form_data">
<p><input type=submit value=submit>
</form>
<?php
include ("/home/mgordon/php/wamex.inc"); //insert your own connect info
dblink ();  //and here
if ($form_data)
   {
$data=addslashes(fread(fopen($form_data, "rb"), 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 DB ID:<b>$id</b>";
    }
?>
</body>
</html>





=====
Mark
[EMAIL PROTECTED]

__________________________________________________
Do You Yahoo!?
Make international calls for as low as $.04/minute with Yahoo! Messenger
http://phonecard.yahoo.com/

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to