Hi,
On 5/6/05, Cima <ruel.cima@facinf.uho.edu.cu> wrote:
> i've uploaded some files into my postgresql db, via a php script,
Are files stored as large objects or simple bytea fields?
> and now
> id like to give a user the posibility to download these files via a php
> script. what would be the best way to do this bearing in mind that the files
> are 'integrated' into the db and are referenced by an oid. the table that
> contains the files has the original filename in one column and the oid of
> the file in another column besides other info on the table.
> any sugestion would be highly apreciated!
I don't advice relying on OIDs. (For further information, you can take
a look at "Object Identifiers" section in PostgreSQL documentation.)
Anyway, you can just output the data from the related table row field.
But before this, you should pass some extra headers to remote client:
<?php
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
header("Content-Type: application/octet-stream");
header("Content-Length: " . $theFileSize);
header("Content-Disposition: attachment; filename=$theFileName");
// outputFileFromDatabase();
?>
Regards.