Insert a file into PostgreSQL BYTEA field using PHP
Your options are:


Use PDO, which properly supports binary parameters; or
Use pg_escape_bytea with string substitution into the query text.


See https://stackoverflow.com/q/17121791/398670 .