Get the filename from the descriptor BFILE : Oracle : Databases PHP Source Code

PHP Source Code » Databases » Oracle »


Get the filename from the descriptor BFILE

Unfortunately there is no direct method in PHP to get the filename from
the descriptor. But if you have (or create) an Oracle procedure you could pass it the BFILE
descriptor and get the name.
Instead of executing the query in PHP and using PL/SQL to find the filename, a more
efficient method is to create a PL/SQL anonymous block that does both the query and
extracts the filename from its returned BFILE.

The previous query code in navioo_bfilequery1.php

$s oci_parse($c,
'declare '
'b_l bfile;'
'da_l varchar2(255);'
'begin '
'select image into b_l from filetest where filenum = :fnum;'
'dbms_lob.filegetname(b_l, da_l, :name);'
$fnum 1;
header("Location: http://localhost/tmp/$name");

The filename cj.jpg is returned in $name courtesy of the :name bind variable argument to the
DBMS_LOB.FILEGETNAME() function. The header() function redirects the user to the
image. If you have problems, comment out the header() call and check that $name is valid.
If any text is printed before the header() is output, the HTTP headers will not be correct and
the image will not display.

HTML code for linking to this page:

Follow Navioo On Twitter

PHP Source Code

 Navioo Databases
» Oracle