Page 1 of 1

Problem saving(or reading) pdf into oracle

Posted: Fri Sep 21, 2007 7:13 am
by yacahuma
I have a form that uploads a pdf into an oracle blob. The code looks something something like this(not the exact code).

Code: Select all

$filename = temp_file_from_form;
$handle = fopen($filename, "r");
$blob_data = fread($handle, filesize($filename));
fclose($handle);

$sql = "Store Procedure with Parameters, one of them the blob";
			

 		$stmt = $db->PrepareSP($sql);
		$db->InParameter($stmt, $id, 'id');
		$blob = $db->InParameter($stmt, $blob_data, 'photo',-1, OCI_B_BLOB);
		$db->StartTrans();
		$ok = $db->Execute($stmt);
The problem is that when I read the file some of the characters looks wrong. The size in the database and in the original file is the same. I am wondering if there is a character set issue.?? Is the problem in the writing or in the reading? I will post the reading code later.



First few characters of each file. Notice the diff characters in the second line

The original

Code: Select all

%PDF-1.3
%âãÏÓ
5 0 obj
<<
/Length 197
/Filter /FlateDecode
>>
The one from the database

Code: Select all

%PDF-1.3
%¿¿¿¿
5 0 obj
<<
/Length 197
/Filter /FlateDecode
>>

Posted: Fri Sep 21, 2007 8:43 am
by feyd
Is there a reason you aren't storing the file in the file system and simply referencing it from the database?

simple. I was asked to do it that way

Posted: Fri Sep 21, 2007 10:22 pm
by yacahuma
simple. I was asked to do it that way. Apparently the database backups are better managed. What bothers me is that it should work. I am sure it will be like a single line fix.