Reply to Re: Incorporating images with Oracle to create a PHP web site.

Your name:

Reply:


Posted by Mladen Gogala on 05/08/06 04:33

On Sat, 06 May 2006 23:01:53 -0700, K. A. wrote:

> However, the above PHP code did not work,

What was the problem? Did you get any errors? I'll probably be able
to help you out, once you give me all the necessary information.

> so I wrote the following
> lines straight into SQL and I got 1 row created.
>
> SQL> insert into file_test (StaffID, staff_name, staff_pic)
> values ('12345', 'Scott Tiger', BFILENAME('Staff_images_dir',
> '12345.jpg'));

Did that work?

>
> My questions.
> 1. How do I create a PHP code to let the user enter his details (ID and
> name) in a form and select a file image (as his personal photo) from a
> particular directory and save everything in the Database.
> 2. How do I go back then (as an admin) and view staff details and
> pictures based on a SELECTed staff ID?

Here is a little ADOdb snippet that I wrote to solve precisely the
same problem. Uploaded the file to a CLOB field, which makes it possible
for me to have web server and Oracle instance on two different machines.

<html>
<head>
<title>Upload File (ADOdb)</title>
</head>

<body>
<?php
require_once('adodb/adodb.inc.php');
require_once('adodb/adodb-exceptions.inc.php');
session_start();
$DSN=$_SESSION['DSN'];
$db=NewADOConnection("oci8");

$INS="insert into poetry(file_desc,file_data)
values (:pdesc,:cont)";
$clob=file_get_contents($_FILES['file']['tmp_name']);

try {
$db->Connect($DSN['database'],
$DSN['username'],
$DSN['password']);
$db->BeginTrans();
$sth=$db->PrepareSP($INS);
$db->InParameter($sth,$_POST['desc'],'pdesc');
$db->InParameter($sth,$clob,'cont',-1,OCI_B_CLOB);
$db->Execute($sth);
}
catch (Exception $e) {
$db->RollbackTrans();
die($e->getTraceAsString());
}
$db->CommitTrans();
?>

<center>
<h2>File <?=$_FILES['file']['name']?>
uploaded successfully!</h2>
</center>
</body>
</html>

I wholeheartedly advise you to use ADOdb as it is logical, reliable,
easy to use, covers different drivers and works with PHP5, which gives
you the ability to utilize exceptions.

--
http://www.mgogala.com

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация