Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 9F4AE475ED4 for ; Thu, 7 Nov 2002 23:40:53 -0500 (EST) Received: from cooee.squiz.net (cooee.cybersydney.com.au [203.25.173.1]) by postgresql.org (Postfix) with SMTP id 2D207475A71 for ; Thu, 7 Nov 2002 23:40:52 -0500 (EST) Received: (qmail 21537 invoked by uid 509); 8 Nov 2002 04:40:58 -0000 Received: from csmith@squiz.net by cooee.squiz.net by uid 0 with qmail-scanner-1.14 ( Clear:. Processed in 0.031505 secs); 08 Nov 2002 04:40:58 -0000 Received: from pc149.cybersydney.com.au (HELO avenger.squiz.net) (203.25.173.149) by cooee.cybersydney.com.au with SMTP; 8 Nov 2002 04:40:57 -0000 Message-Id: <5.1.0.14.0.20021108154207.03192b70@cooee.squiz.net> X-Sender: csmith@cooee.squiz.net X-Mailer: QUALCOMM Windows Eudora Version 5.1 Date: Fri, 08 Nov 2002 15:45:54 +1100 To: "Zhidian Du" , pgsql-php@postgresql.org From: Chris Smith Subject: Re: Are these steps correct and standard way to upload In-Reply-To: Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii"; format=flowed X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200211/31 X-Sequence-Number: 1613 Hi, >I check the posts about uploading images from browser. No one give me a >whole procedure how to do it. My friend told me I can upload binary/image >file using following steps: > >I want to know are these steps standard steps that insert images into a table? > > >Step 1 upload it >
>upload size=40>
> > if($pic_name != '') > { > $len = strlen($pic_name)-4; > $ext = substr($pic_name,$len); > $ext = strtolower($ext); > > $File="/www/pics/test".$ext; > exec("cp $pic $File"); Use the move_uploaded_image function in PHP. Safer and easier. > } > > >?> > >Step 2 Read it >$fd = fopen($img_name, "r"); > while ($post_file = fread($fd, 4096)) > { > $filestuff .= $post_file; > } > fclose($fd); > > >Step 3 insert or update into the table using insert or update Are you sure you want to keep the file in the database? It will bloat it out quite a bit (depending on the size and type of your files of course). Why need keep either a filename or filepath and just store the file itself on the machine ? Anyway, check out the pg_lo_import function in the PHP manual for a starting point. Chris .....>> Open Source - Own it - Squiz.net ...../> W: http://www.squiz.net/ .....>> Open Source - Own it - Squiz.net ...../>