Tutorial/Example of Insert/Select PDF Postgres DB ?

Tutorial/Example of Insert/Select PDF Postgres DB ?

am 09.10.2006 06:53:32 von ben wilko

Hi Guys

I am looking for an examples on how to insert a PDF file into Postgres DB
and also selecting it so that someone can download it from a page.

Thanx

Ben :)



---------------------------(end of broadcast)---------------------------
TIP 1: if posting/reading through Usenet, please send an appropriate
subscribe-nomail command to majordomo@postgresql.org so that your
message can get through to the mailing list cleanly

Re: Tutorial/Example of Insert/Select PDF Postgres DB ?

am 09.10.2006 07:28:33 von Chris

ben wilko wrote:
> Hi Guys
>
> I am looking for an examples on how to insert a PDF file into Postgres
> DB and also selecting it so that someone can download it from a page.

You would be much better off storing the path to the file (or just the
filename) in the database, leaving the file itself on the filesystem and
password protecting the downloads folder with a .htaccess file or something.

You could then have something like download.php?file=filename.txt and go
from there (it would use fpassthru to just spit the file out to the
browser etc)..

--
Postgresql & php tutorials
http://www.designmagick.com/

---------------------------(end of broadcast)---------------------------
TIP 1: if posting/reading through Usenet, please send an appropriate
subscribe-nomail command to majordomo@postgresql.org so that your
message can get through to the mailing list cleanly

Re: Tutorial/Example of Insert/Select PDF Postgres DB ?

am 09.10.2006 07:51:46 von Chris

Firstly always CC the mailing list.

ben wilko wrote:
> I am looking to have a dynamic page which will allow users to select
> categories in which a corresponding PDF file will be accessible to them.

That doesn't make any difference.. It becomes two database tables:

create table downloadfile (fileid serial primary key, filename text);
create table downloadfile_categories (fileid int references downloadfile
(fileid), categoryid int references categories (categoryid));

then a file can be available for multiple categories and so on.


If you really want to store binary data in the database, start here:

http://www.postgresql.org/docs/8.1/static/datatype-binary.ht ml

and here:

http://php.net/pg_escape_bytea

--
Postgresql & php tutorials
http://www.designmagick.com/

---------------------------(end of broadcast)---------------------------
TIP 2: Don't 'kill -9' the postmaster

Re: Tutorial/Example of Insert/Select PDF Postgres DB ?

am 14.10.2006 06:57:54 von ben wilko

thank you chris for your solution :)



>From: Chris
>To: ben wilko
>CC: pgsql-php@postgresql.org
>Subject: Re: [PHP] Tutorial/Example of Insert/Select PDF Postgres DB ?
>Date: Mon, 09 Oct 2006 15:51:46 +1000
>
>Firstly always CC the mailing list.
>
>ben wilko wrote:
>>I am looking to have a dynamic page which will allow users to select
>>categories in which a corresponding PDF file will be accessible to them.
>
>That doesn't make any difference.. It becomes two database tables:
>
>create table downloadfile (fileid serial primary key, filename text);
>create table downloadfile_categories (fileid int references downloadfile
>(fileid), categoryid int references categories (categoryid));
>
>then a file can be available for multiple categories and so on.
>
>
>If you really want to store binary data in the database, start here:
>
>http://www.postgresql.org/docs/8.1/static/datatype-binary.h tml
>
>and here:
>
>http://php.net/pg_escape_bytea
>
>--
>Postgresql & php tutorials
>http://www.designmagick.com/
>
>---------------------------(end of broadcast)---------------------------
>TIP 2: Don't 'kill -9' the postmaster



---------------------------(end of broadcast)---------------------------
TIP 3: Have you checked our extensive FAQ?

http://www.postgresql.org/docs/faq