Thread: Tutorial/Example of Insert/Select PDF Postgres DB ?
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 :)
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/
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.html and here: http://php.net/pg_escape_bytea -- Postgresql & php tutorials http://www.designmagick.com/
thank you chris for your solution :) >From: Chris <dmagick@gmail.com> >To: ben wilko <wilko_ben@hotmail.com> >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.html > >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