note 70724 added to function.ociloadlob
| From: | FaLL3N at mail dot ru | Date: | Wed, 25 Oct 2006 13:34:29 +0000 |
| Subject: | note 70724 added to function.ociloadlob | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-119098@lists.php.net to get a copy of this message | ||
I'll give you example how to download a file from db without storing it on server's FS:
It works like this - point yor browser to index.php?name=file.ext
Just make sure that file "file.ext" exists in your db!
Code:
<?php
$dbConnection=ocilogon('user','pass','data.world'); //login stuff
$sql_SelectBlob='select document_body,filename from tdocuments where id=1'; //selecting a
blob field named 'document_body' with id = 1
$statement=OCIParse($dbConnection,$sql_SelectBlob);
OCIExecute($statement) or die($sql_SelectBlob.'<hr>');
if(OCIFetch($statement)) //if file exists
{
$a=OCIResult($statement,"DOCUMENT_BODY");
}
header('Content-type: application/octet-stream;');
header('Content-disposition: attachment;filename='.$_GET['name']);
print $a->load();
//browser promts to save or open the file
?>
Have fun!
----
Server IP: 195.248.191.91
Probable Submitter: 194.44.195.34 (proxied: 192.168.5.29, unknown)
----
Manual Page -- http://www.php.net/manual/en/function.ociloadlob.php
Edit -- https://master.php.net/note/edit/70724
Del: integrated -- https://master.php.net/note/delete/70724/integrated
Del: useless -- https://master.php.net/note/delete/70724/useless
Del: bad code -- https://master.php.net/note/delete/70724/bad+code
Del: spam -- https://master.php.net/note/delete/70724/spam
Del: non-english -- https://master.php.net/note/delete/70724/non-english
Del: in docs -- https://master.php.net/note/delete/70724/in+docs
Del: other reasons-- https://master.php.net/note/delete/70724
Reject -- https://master.php.net/note/reject/70724
Search -- https://master.php.net/manage/user-notes.php