Downloading blob file from oracle8
| From: | Mo | Date: | Fri, 04 Feb 2005 14:56:38 +0000 |
| Subject: | Downloading blob file from oracle8 | ||
| Groups: | php.test | ||
| Request: | Send a blank email to php-test+get-687@lists.php.net to get a copy of this message | ||
Hi everyboddy,
i have a problem in downloading a file wich is saved as a blob in oracle 8
database. My script works the first time that i ask to download a file, but
after that it dosent work anymore properly, the browser start printing out
the file in the same page from where i asked to download it, even if i forse
the download. i dont have anymore any idea how to work it out.
the download fucntion is make like this:
function userDownloadBlob($id_file){
//DB connection
$dsn=$this->db_cn;
$cn=ocilogon($dsn['username'], $dsn['password'], $dsn['hostspec'])
or
die("connessione al DB impossibile");
$strSql = "SELECT BLOBDATA FROM is_file WHERE id_file = ".$id_file."";
$statment = OCIParse ($cn, $strSql);
OCIExecute($statment, OCI_DEFAULT);
OCIFetchInto($statment, $row, OCI_ASSOC+OCI_RETURN_LOBS);
$result = $row['BLOBDATA'];
$strSql2="SELECT file_name,formate,size FROM is_file WHERE
id_file=".$id_file."";
$statement2= ociparse($cn, $strSql2) or die ("non fa parse");
ociexecute ($statement2) or die ("non riesco ad eseguire la query");
ocifetchInto ($statement2, $row2, OCI_NUM);
$filename=$row2[0];
$file_extension=$row2[1];
$size=$row2[3];
//Use the switch-generated Content-Type
header("Content-Type: application/octetstream");
//Force the download
$header="Content-Disposition: attachment; filename=".$row2[0];
header($header );
header("Content-Transfer-Encoding: binary");
header("Content-Description: PHP Generated Data");
header("Content-Length: ".strlen($result));
ocifreestatement($statement2);
OCIFreeStatement($statment);
OCILogoff($cn);
return $result;
}
hope to have some help from u,
thank u,
Mo Chreih