Greets,
Register globals are to off - however the files will not upload.
At wit's end - help please!
Thank all in advance.
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'";
$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