Fw: working with blobs in a two-server setup

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]



Without a code sample it is pretty hard to offer any specific advice about 
what you are doing wrong.

Here is what I used to load some files.  All the $file____ variables are 
set above this block.

        $localname = "/home/tdyson/" . $filename;
        $fp = fopen($localname,"r");
        $buffer = fread($fp,filesize($localname));
        fclose($fp);
        $conn = pg_connect("host=myhost.sybex.com port=5432 dbname=my_db 
user=my_name password=my_password ");
        pg_query ($conn, "begin");
        $oid = pg_lo_create ($conn);
 
        $rs = pg_exec($conn,"insert into download_links (file_size, 
file_name, file_date, product_id, file_version, the_file) 
                        values('" . $filesize . "','" .  $filename . "','" 
.$filedate . "','" .  $product_id . "','" . $fileversion . "','" .  $oid . 
"')");     // the_file field type must be "oid"
 
        $handle = pg_lo_open ($conn, $oid, "w");

        pg_lo_write ($handle, $buffer);
        pg_lo_close ($handle);
        pg_query ($conn, "commit"); 
        pg_close();


Thom Dyson
Director of Information Services
Sybex, Inc.
 


pgsql-php-owner@xxxxxxxxxxxxxx wrote on 10/27/2004 12:42:34 AM:

> Hi everyone,

> I have a two server setup (both debian stable) with apache and the
> PHP engine on server1 and postgresql on server2. My application
> should be able to store BLOBs in the database. In a test environment
> where everything was running on a single server it was OK (I used
> the ADBOdb lo functions there) but now I get into all sorts of
> trouble: the database can't find the uploaded file, which makes
> sense: it's in /tmp on server1! :-(

> Does anyone know how I can handle this or have a pointer to a howto?

> Thanks!

> 
> ---------------------------(end of broadcast)---------------------------
> TIP 1: subscribe and unsubscribe commands go to majordomo@xxxxxxxxxxxxxx


[Index of Archives]     [Postgresql General]     [Postgresql Admin]     [PHP Users]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Databases]     [Yosemite Backpacking]     [Postgresql Jobs]

  Powered by Linux