Answer the question
In order to leave comments, you need to log in
How to save a file in Postgresql database?
How to save a file (*.doc,*.png ...) to the database. What type should the cell have and the Sql command itself to save to the database
Answer the question
In order to leave comments, you need to log in
If the file is small, then you can stuff it into a field like bytea
create table images(id int, image bytea);
insert into images values (1, pg_read_file('/path/to/image.jpg')::bytea);
create table images (id int, image oid);
insert into images values (1, lo_import('/path/to/image.jpg'));
It is better not to store files in the database at all. Depending on the project, the path to the file can be various relative or absolute links, or data for generating them.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question