John W. Holmes <[EMAIL PROTECTED]> wrote in message:
> Remember... we're laughing with you, not at you. You forgot to call
> mysql_query() in your code. :)
.................
Hmmm... I wish it was as simple as that.
I inserted the mysql_query() below
but it still doesn't upload the file nor does it throw an error.
If you get a chance please take a look and advise.
Again, my thanks for your help,
TR
................................
<?
if ($submit) {
// connect to the database
// (you may have to adjust the hostname,username or password)
MYSQL_CONNECT("localhost","root","mypass");
mysql_select_db("mydb");
$uploadfile = $_FILES['form_data']['tmp_name'];
$uploadname = $_FILES['form_data']['name'];
$uploadtype = $_FILES['form_data']['type'];
$uploaddesc = $_POST['desc'];
// Open file for binary reading ('rb')
$tempfile = fopen($uploadfile,'rb');
// Read the entire file into memory using PHP's
// filesize function to get the file size.
$filedata = fread($tempfile,filesize($uploadfile));
// Prepare for database insert by adding backslashes
// before special characters.
$filedata = addslashes($filedata);
// Create the SQL query.
$sql = "INSERT INTO binary_data SET
filename = '$uploadname',
filetype = '$uploadtype',
description = '$uploaddesc',
bin_data = '$filedata'";
$ok = @mysql_query($sql);
if(!$ok)die('Database error storing the file:'.mysql_error());
$id= mysql_insert_id();
print "<p>This file has the following Database ID: <b>$id</b>";
echo "<br>";
echo "<a href=\"getdata.php?id=$id\">Click to view file</a>";
MYSQL_CLOSE();
} else {
// else show the form to submit new data:
?>
<form method="post" action="<?php echo $PHP_SELF; ?>"
enctype="multipart/form-data">
<p>File Description:<br>
<input type="text" name="desc" 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
}
?>
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php