Jump to content

Storing and retrieving files into postgreSQL ( or mysql )


thales.pereira

Recommended Posts

Hi, im trying to store and retrieve some small files ( 3k min 15k max ) into a table, but until now only figure out how to store

 

I dont know if this is the best way, but i think it works ( i dont know if it stores the file right into the table, but i can see the table growing )

 

<?php
#bd config
include 'config.php';
#bd call
include 'opendb.php';

$name='node.ndf';

$fp = fopen($name, 'rb');
$content = fread($fp, filesize($name));
$content = pg_escape_string($content);

$sql=("insert into storage values ('$content'::bytea)");
pg_query($sql) or die(pg_last_error());
?>

 

But how do i extract those files from the table?

 

 

PS: the postgresqlField to store is bytea.

 

 

Regards,

Thales Pereira

 

Sorry the double post, but anyone belive this is a better solution? instead storing the file, i could store the information of the file into a field, and when i need it i could extract the data to a local file.

 

 

<?xml version="1.0" encoding="UTF-8"?>

<Values version="2.0">
  <value name="node_type">ConnectionData</value>
  <value name="node_nsName">Adapters:Qry</value>
  <value name="node_pkg">Adapters</value>
  <value name="IRTNODE_VERSION">1</value>
  <value name="IRTNODE_PROPERTY">CwQAAAABBQEEGQBjAG8AbQAuAHcAbQAuAGQAYQB0AGEALgBJAFMATQBlAG0ARABhAHQAYQBJAG0AcABsBBUAYwBvAG4AbgBlAGMAdABpAG8AbgBOAG8AZABlAFYAZQByAHMAaQBvAG4LBAAAAAEEDwBhAGQAYQBwAHQAZQByAFQAeQBwAGUATgBhAG0AZQQLAEoARABCAEMAQQBkAGEAcAB0AGUAcgQZAGMAbwBuAG4AZQBjAHQAaQBvAG4ARgBhAGMAdABvAHIAeQBUAHkAcABlAE4AYQBtAGUENgBjAG8AbQAuAHcAbQAuAGEAZABhAHAAdABlAHIALgB3AG0AagBkAGIAYwAuAGMAbwBuAG4AZQBjAHQAaQBvAG4ALgBKAEQAQgBDAEMAbwBuAG4AZQBjAHQAaQBvAG4ARgBhAGMAdABvAHIAeQQUAGMAbwBuAG4AZQBjAHQAaQBvAG4AUAByAG8AcABlAHIAdABpAGUAcwUBAAIEDwB0AHIAYQBuAHMAYQBjAHQAaQBvAG4AVAB5AHAAZQQOAE4ATwBfAFQAUgBBAE4AUwBBAEMAVABJAE8ATgQPAGQAYQB0AGEAcwBvAHUAcgBjAGUAQwB</value>
</Values>

 

Sugestions?

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.