What is wrong with this code ??
Posted: Fri Sep 26, 2003 10:26 am
I am trying to insert an uploaded file into oracle database - blob field from a PHP script.
Below is my code, could you please tell where I am doing something wrong. It doest give me any error while running it, but it doesnt save data into the table either.
PLEASE HELP !!
Thanks in advance
Below is my code, could you please tell where I am doing something wrong. It doest give me any error while running it, but it doesnt save data into the table either.
PLEASE HELP !!
Thanks in advance
Code: Select all
<?php
include_once("header.inc.php");
include_once("config.php");
include_once("adodb/adodb.inc.php");
$person_id = $_POST['PID'];
$filename = $_FILES['userfile']['name'];
$uploaddir = "check/". $_FILES['userfile']['name'];
echo " The older file location is : $uploaddir";
$file_dest = str_replace("","/",$uploaddir);
echo " The new file location is $file_dest";
$up = move_uploaded_file($_FILES['userfile']['tmp_name'], $file_dest);
chmod($uploaddir,0644);
chmod($file_dest,0644);
//var_dump($up);
if($up)
{
// echo "File uploaded";
$query1 = "SELECT application_id
FROM application_info
WHERE person_id = $person_id";
$app_result = $db->Execute($query1);
$app_id = $app_result->fields[0];
?>
<p><?php echo "Application ID found is : $app_id"; ?> </p>
<?php
$query2 = "SELECT application_material_id
FROM application_material
WHERE material_type like 'Transcript'";
$mat_result = $db->Execute($query2);
$app_mat_id = $mat_result->fields[0];
?>
<p><?php echo "Application Material ID found is : $app_mat_id"; ?> </p>
<?php
$main_query = "INSERT INTO submitted_material_list
(Application_Material_ID,
Application_ID,
Physical_Copy,
Rec_By,
Rec_Date)
VALUES (1,
$app_id,
LOAD_FILE("$file_dest"),
$app_id,
SYSDATE)";
$result = $db->Execute($main_query);
$query3 = "SELECT physical_copy
FROM submitted_material_list
WHERE application_material_id = 1
AND application_id = $app_id
AND Rec_Date=SYSDATE";
$found = $db->Execute($query3);
if($found)
{
echo "DATA SAVED !!";
}
else
{
echo " NOT SAVED !!";
}
}
else
{
echo "Not uploaded";
}
?>