Received: from icebox.venux.net (icebox.venux.net [216.120.166.10]) by mail.postgresql.org (8.11.1/8.11.1) with ESMTP id eASHj5t61966 for ; Tue, 28 Nov 2000 12:45:05 -0500 (EST) (envelope-from mitch@venux.net) Received: from windows (cx853045-b.phnx1.az.home.com [24.177.75.28]) by icebox.venux.net (Postfix) with SMTP id 6E3C126202; Tue, 28 Nov 2000 12:57:24 -0500 (EST) Message-ID: <00d101c0596c$0d339c00$0200000a@windows> From: "Mitch Vincent" To: , References: <3A23B26E.9056.2942B3@localhost> Subject: Re: Question re large objects Date: Tue, 28 Nov 2000 10:50:17 -0800 MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 5.50.4133.2400 X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4133.2400 X-Archive-Number: 200011/22 X-Sequence-Number: 30 > (Hopefully I'm addressing this to the right list... This is my first time > with BLOBs anywhere.) > > I'm working on a web page template system (PHP/PostgreSQL) > which will (in part, other stuff is done) allow users to upload a gif or > jpeg via a form on another site. The image will then slot into a > predetermined place on their template website. > > I've considered the alternatives (store files in a directory or in the > db), and I think storing the image files in the database is the way to > go. Unless anybody can think of why I should just upload the files > to a directory on the server instead of storing them as BLOBs. In 7.0.X there is a limit on the size of tuples, 32k, and some images could easily be bigger than that (though it depends on your images I guess). 7.1 will be out shortly after the first of the year and will take care of this though. Depending on the use of these images, I'd think up a naming scheme and store them as flat-files and perhaps store the image name or something in the database... You could still display a link to the images but the link would have to be to a PHP (or other) script that would grab the image from the database, set the MIME type and display it to the browser -- you couldn't have it in an HTML document without first writing it to a flat file (at least I don't know of a way you could display it in an HTML document) . > I can upload a binary file just fine, and retrieve it from the database > just fine. The problem is that the file (using pg_loreadall) just > plunks itself into my test page as text/plain. How do I get a mime > type header associated with this data so my browser will recognize > it as a gif or jpeg? Do I have to export the file to a web-accessible > directory (owned by web server user, I know) and then use an > tag? Or is there a way to get my browser to recognize that > the BLOB is in fact an image when PHP pulls it out of the > PostgreSQL database? The MIME type is image/jpeg for jpegs and image/gif for gifs. Use PHP's header() function. > Be gentle if I've asked a stupid question... :-) There are no stupid questions, only stupid answers! -Mitch