Problem saving(or reading) pdf into oracle

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
yacahuma
Forum Regular
Posts: 870
Joined: Sun Jul 01, 2007 7:11 am

Problem saving(or reading) pdf into oracle

Post 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
>>
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

Is there a reason you aren't storing the file in the file system and simply referencing it from the database?
User avatar
yacahuma
Forum Regular
Posts: 870
Joined: Sun Jul 01, 2007 7:11 am

simple. I was asked to do it that way

Post 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.
Post Reply