Hi,
i want to write into a ACCESS DB over ODBC.
I am using that code:
<?php
$conn = odbc_connect("mydb", "Sa", "") or die ('Error connecting to mysql');
?>
<html>
<head>
<title>Upload File To Database</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
<?
if(isset($POST['upload']))
{ $fileName = $FILES['userfile']['name'];
$tmpName = $FILES['userfile']['tmp_name'];
$fileSize = $FILES['userfile']['size'];
$fileType = $_FILES['userfile']['type'];
$fp = fopen($tmpName, 'r');
$content = fread($fp, $fileSize);
$content = addslashes($content);
fclose($fp);
if(!get_magic_quotes_gpc())
{ $fileName = addslashes($fileName); }
print $fileName;
print $fileSize;
print $fileType;
$query = "INSERT INTO file (filename, filesize, filetype, filecontent ) VALUES ('$fileName', '$fileSize', '$fileType', '$content')";
odbc_longreadlen($queryexe , 2000000);
odbc_binmode($queryexe , ODBC_BINMODE_RETURN);
$queryexe = odbc_exec($conn, $query) or die('Error, query failed');
echo "<br>File $fileName uploaded<br>";
}
?>
<form action="" method="post" enctype="multipart/form-data" name="uploadform">
<table width="350" border="0" cellpadding="1" cellspacing="1" class="box">
<tr>
<td width="246"><input type="hidden" name="MAX_FILE_SIZE" value="2000000"><input name="userfile" type="file" class="box" id="userfile">
</td>
<td width="80"><input name="upload" type="submit" class="box" id="upload" value=" Upload "></td>
</tr>
</table>
</form>
</body>
</html>
i got that code from here -> http://www.php-mysql-tutorial.com/php-mysql-upload.php
it was originally a code for uploading files to mysql and i changed it to ODBC-code.
I want to keep it as general as possible - also if performance decreases - because i want to have it general and migrate so mysql later.
Strange: the upload only works with very small files.
I tried out several things with odbc_longreadlen() and odbc_binmode() but nothing helped.
does somebody has an idea?
-> by the way: if somebody knows a good and general tutorial how to handle/upload BLOB s would be great.
Am php newbie.
Thx for help!
PL