Open Source Development Tutorials | Newsletter Signup | About Us
Search  

Go Back   Open Source Tutorials Forum > Databases > PostgreSQL
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read


Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 01-27-2005, 04:54 AM
wingchun wingchun is offline
Junior Member
 
Join Date: Jun 2004
Posts: 4 wingchun is on a distinguished road
Default The way to insert image file into postgresql

Hallo to all,
I have a problem,
i have a java application (stand alone) and it works with Postgresql.
My problem is that i'm not able to put(and read and so on...) an image file into a table of Postgresql.
So i wish to know wich is the best way to do this.
Thanks.
Reply With Quote
  #2  
Old 01-29-2005, 06:05 PM
md_doc md_doc is offline
ubergeek
 
Join Date: Oct 2003
Posts: 204 md_doc has disabled reputation
Default

I would think you would need to read the file in as a binary file and save it as a binary type in the database then when you take it back out pretend the buffer is a pointer to the file data and just show it.

I know it is easier said than done but as to the exact steps you have to take with java I am not sure Unless you just save the image somewhere as a flat file and store the location in pgsql.
__________________
md
Reply With Quote
  #3  
Old 12-22-2005, 10:52 PM
PriceComparison PriceComparison is offline
Junior Member
 
Join Date: Nov 2004
Posts: 1 PriceComparison is on a distinguished road
Talking I can give a clue about how to do this

I am not at liberty to just cut-and-paste my code from work. But I can give some clues and direction. Unfortunately it is not just as easy as just "...just show it..." heehehe... that was funny.

First you have to store the image data as binary (BLOB). Then when retreiving it comes back as one large string. This is the clue. Use a PHP function to redirect output to a certain file type such as GIF or JPEG.

This is demonstrated at http://www.PriceComparison.com. All of our image files are generated by a PHP script which pulls from database.

Good Luck

Andrew - DBA for http://www.PriceComparison.com
Reply With Quote
  #4  
Old 12-23-2005, 08:33 AM
md_doc md_doc is offline
ubergeek
 
Join Date: Oct 2003
Posts: 204 md_doc has disabled reputation
Default

That is very true. I did not even think about it.

Take a php script that takes an argument via the get param... image_id or something. Have that call the database get the information from the BLOB and then set the header to a gif or jpg or whatever kind of image it is then just echo out the content. It should display just fine.
__________________
md
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump



All times are GMT -5. The time now is 11:16 PM.


Powered by: vBulletin Version 3.0.1
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright 2004 - 2006 GrindingGears.com. All Rights Reserved.