how to save file into postgresql database

you need a column in a postgresql table with the type OID

create table files(
file_id serial primary key,
file oid not null
);

to insert file

INSERT INTO files(file) values(lo_import('/tmp/filename.ext');

to read the file

SELECT lo_export(file, '/tmp/filename.ext') WHERE file_id=2;

you can get the file in the /tmp/filename.ext.

store upload image postgresql

Advertisements

Published by

paragasu

Different. In a good way

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s