binary data into postgresql in bytea

From: Date: Mon, 09 Feb 2004 20:09:26 +0000
Subject: binary data into postgresql in bytea
Groups: php.db 
Request: Send a blank email to php-db+get-32871@lists.php.net to get a copy of this message
HI! I wrote the code how to upload and insert binary data into postgresql. <?php $original_tmp = $_FILES['UploadedFile']['tmp_name']; $original_name = $_FILES['UploadedFile']['name']; $original_size = $_FILES['UploadedFile']['size']; $original_type = $_FILES['UploadedFile']['type']; print("<hr>\n"); $fileHandle = fopen($original_tmp, "r"); $binaryContent = fread($fileHandle, $original_size); $binaryContent = pg_escape_bytea($binaryContent); fclose($fileHandle); $sql_insert = "INSERT INTO objects(b_col, file_name, file_size, file_type, file_date) VALUES ('$binaryContent'::bytea,'$original_name','$original_size','$original_type',now())"; pg_query($sql_insert) or DIE ("Could not perform INSERT to table: ".pg_lst_error()); ?> Does anyone know right code? I do not think this is write code for postgresql. The field which binary data is stored is "bytea." Regards, hiro

« previous php.db (#32871) next »