Storing images in bytea fields in a PostgreSQL database
I stored an image in a PostgreSQL database with column type bytea using PHP. The problem is every time I try to load the image in a browser it does not appear. The Firefox developer console says the image is either truncated or corrupt. The PHP code: //code for inserting into the database if(array_key_exists('submit_pic', $_POST)){ $user=$_SESSION['name']; if(isset($_FILES['thumbnail'])&&$_FILES['thumbnail']['size']>0){ $fi = $_FILES['thumbnail']['tmp_name']; $p=fopen($fi,'r'); $data=fread($p,filesize($fi)); $data=addslashes($data); $dat= pg_escape_bytea($data); $q="update userinfo set image='