Re: downloading files

Поиск
Список
Период
Сортировка
От Volkan YAZICI
Тема Re: downloading files
Дата
Msg-id 7104a73705050604261fc88551@mail.gmail.com
обсуждение исходный текст
Ответ на downloading files  ("Cima" <ruel.cima@facinf.uho.edu.cu>)
Список pgsql-novice
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.

В списке pgsql-novice по дате отправления:

Предыдущее
От: "Cima"
Дата:
Сообщение: downloading files
Следующее
От: Vidya
Дата:
Сообщение: cursor problem