Hi,
I modified your code but cannot display the picture uploaded, only a 'cross' sign displayed.
I use apache 2.0.54, php 4.3.6, win2k, oracle 10g, ado 4.11.
When I enable sql-debugging and print_r($_FILEs), I got below infos when I click 'upload':
Array
(
userfile => Array
(
name => box1.JPG
type => image/pjpeg
tmp_name => c:\tmp\php16.tmp
error => 0
size => 18913
)
)
<hr />
(oci8): ALTER SESSION SET NLS_DATE_FORMAT='YYYY-MM-DD' <code></code>
<hr />
filename=c:\tmp\php16.tmp
id=1
path=c:\tmp\php16.tmp
<hr />
(oci8): INSERT INTO BTAB (BLOBID, BLOBDATA) VALUES (1, EMPTY_BLOB()) <code></code>
<hr />
<hr />
(oci8): UPDATE BTAB set BLOBDATA=EMPTY_BLOB() WHERE BLOBID=1 RETURNING BLOBDATA INTO :blob <code></code>
<hr />
name=:blob var=Object len=-1 type=113
<hr />
(oci8): SELECT BLOBDATA FROM BTAB WHERE BLOBID = 1 <code></code>
<hr />
ÿÃÿà JFIF°°ÿÃCÿÃCÿÃâ¬â¬"ÿÃ
ÿõ}!1AQa"q2Ââ¡#B±ÃRÃð$3brâ
%&'()*456789:CDEFGHIJSTUVWXYZcdefghijstuvwxyzÆââ¦â â¡Ëâ°Å ââââ¢ââËâ¢Å¡Â¢Â£Â¤Â¥Â¦Â§Â¨Â©ÂªÂ²Â³Â´ÂµÂ¶Â·Â¸Â¹ÂºÃÃÃÃ
ÃÃÃÃÃÃÃÃÃÃÃÃÃÃáâãäåæçèéêñòóôõö÷øùúÿÃ
ÿõw!1AQaq"2ÂB⡱à #3RðbrÃ
$4á%ñ&'()*56789:CDEFGHIJSTUVWXYZcdefghijstuvwxyzâÆââ¦â â¡Ëâ°Å ââââ¢ââËâ¢Å¡Â¢Â£Â¤Â¥Â¦Â§Â¨Â©ÂªÂ²Â³Â´ÂµÂ¶Â·Â¸Â¹ÂºÃÃÃÃ
ÃÃÃÃÃÃÃÃÃÃÃÃÃÃâãäåæçèéêòóôõö÷øùúÿÃ?óüEcãYeð÷®Â4Y´ûø¬âñ´šÃzdW`âº7Ã5iµâ¹â°IPFÃâ Df(ÃÃèž ýâ¢>&EÂÃ|<OÃxÃGñ=â]ø>öÃVÿ±<Iÿøâ¹Vð·ŠôÃÅ¡ÃÃÃeâæ)Ãâ¬Ã²Â¤â¹µâ3ì'â¦Â¿c_Ãâ¹Ã?OżUã?
üZñ^âcšçOøYâ=;PÃ&¶ââOìK_k:gö½ââ¡Ãà <°ÂBÃÃwÃ
?¿n?ÃCwáÃÃãáWÂ<%}
Seems the contents is processed but not displaying well.
I have set
file_uploads = On
upload_tmp_dir = "c:\tmp"
upload_max_filesize = 6M
in c:\program files\php.ini
and enabled this dir as everyone 'full control', when at this time, when I dir this folder, no php16.tmp is found.
here's my code:
<?php
include_once("adodb.inc.php");
define('MYBLOBID', 1); // should really be a unique id e.g. a sequence number
define("ORA_CON_UN_01", "sh");
define("ORA_CON_PW_01", "sh");
define("ORA_CON_DB_01", "ORACA");
function checkfile()
{
$fn = $_FILES;
// echo "file tmpname is:".$fn."\n";
// echo "file type is:".$_FILES."\n";
// echo "file size is:".$_FILES."\n";
// echo "file information is:".$_FILES."\n";
// print_r($_FILES);
if (!file_exists($fn))
error('File check', 'Can not find file '.$fn);
return($fn);
}
function myconnect()
{
$db = ADONewConnection("oci8");
// $db->debug = true;
if (!@$db->Connect(false, ORA_CON_UN_01, ORA_CON_PW_01, ORA_CON_DB_01))
error('Connect', $db->ErrorMsg());
return $db;
}
function deleteblob($db, $id)
{
if (!$db->Execute('DELETE FROM BTAB WHERE BLOBID='.$id))
error('Delete failed', $db->ErrorMsg());
}
function insertblob($db, $id, $path)
{
echo "id="."$id"."\n";
echo "path="."$path"."\n";
if (!$db->Execute('INSERT INTO BTAB (BLOBID, BLOBDATA) VALUES ('.$id.', EMPTY_BLOB())'))
error('Insert failed', $db->ErrorMsg());
if (!$db->UpdateBlobFile('BTAB', 'BLOBDATA', $path,'BLOBID='.$id, 'BLOB'))
error('UpdateBlobFile failed', $db->ErrorMsg());
}
function displayimage($db, $id)
{
if (!$rs = $db->Execute("SELECT BLOBDATA FROM BTAB WHERE BLOBID = ".$id))
// if (!$rs = $db->Execute("SELECT BLOBDATA FROM BTAB WHERE BLOBID = "4"))
error('Error selecting', $db->ErrorMsg());
// If any text (or whitespace!) is printed before this header is sent,
// the text won't be displayed and the image won't display properly.
// Comment out this line to see the text and debug such a problem.
header("Content-type: image/pJPEG");
$row = $rs->FetchRow();
print $row[0];
}
function error($w, $m)
{
echo "$w: $m";
die;
}
if (isset($_FILES)) {
$fn = checkfile();
$db = myconnect();
$imagenum=$_POST;
print "filename="."$fn"."\n";
// echo "dbname="."$db"."\n";
// echo "imagenum="."$imagenum"."\n";
// deleteblob($db, MYBLOBID);
insertblob($db, $imagenum , $fn);
displayimage($db, $imagenum);
exit;
}
?>
<html>
<head><title>Upload BLOB images with ADOdb</title></head>
<body>
<form enctype="multipart/form-data"
action="<?php echo $_SERVER; ?>" method="POST">
Image Filenumber: <input name="imagenum" type="text">
Image Filename: <input name="userfile" type="file">
<input type="submit" value="Upload">
<input type="hidden" name="MAX_FILE_SIZE" value="3000">
</form>
<HR>
<table align='center' border='0'>
<tr>
<td align='center' width='150'>
<form Action='display.php'>
<INPUT TYPE="submit" VALUE="Display">
</form>
</td>
<td align='center' width='150'>
<form>
<input type="button" value="Back" onclick="self.history.back();">
</form>
</td>
<td align='center' width='150'>
<form Action='index.html'>
<INPUT TYPE="submit" VALUE="Back to Main">
</form>
</td>
</tr>
</table>
<HR>
</BODY>
</HTML>
Anybody can help?
THX a lot!