pg.ddx.io pgsql-php@postgresql.org mailing list archive
help / color / mirror / Atom feedAre these steps correct and standard way to upload images into a table?
3+ messages / 3 participants
[nested] [flat]
* Are these steps correct and standard way to upload images into a table?
@ 2002-11-08 04:32 Zhidian Du <duzhidian@hotmail.com>
0 siblings, 1 reply; 3+ messages in thread
From: Zhidian Du @ 2002-11-08 04:32 UTC (permalink / raw)
To: pgsql-php
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
<FORM METHOD=POST ACTION="" enctype="multipart/form-data">
<tr><td>upload </TD><TD><input type="file" name="pic"
size=40></td></tr></form>
<?
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");
}
?>
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 these steps correct or the standard way to upload images into a table?
Thanks.
Zhidian Du
_________________________________________________________________
Protect your PC - get McAfee.com VirusScan Online
http://clinic.mcafee.com/clinic/ibuy/campaign.asp?cid=3963
^ permalink raw reply [nested|flat] 3+ messages in thread
* Re: Are these steps correct and standard way to upload
@ 2002-11-08 04:45 Chris Smith <csmith@squiz.net>
parent: Zhidian Du <duzhidian@hotmail.com>
0 siblings, 1 reply; 3+ messages in thread
From: Chris Smith @ 2002-11-08 04:45 UTC (permalink / raw)
To: Zhidian Du <duzhidian@hotmail.com>; pgsql-php
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
><FORM METHOD=POST ACTION="" enctype="multipart/form-data">
><tr><td>upload </TD><TD><input type="file" name="pic"
>size=40></td></tr></form>
>
><?
> 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 ...../>
^ permalink raw reply [nested|flat] 3+ messages in thread
* Re: Are these steps correct and standard way to upload
@ 2002-11-11 23:38 Papp Gyozo <pgerzson@freestart.hu>
parent: Chris Smith <csmith@squiz.net>
0 siblings, 0 replies; 3+ messages in thread
From: Papp Gyozo @ 2002-11-11 23:38 UTC (permalink / raw)
To: Chris Smith <csmith@squiz.net>; Zhidian Du <duzhidian@hotmail.com>; pgsql-php
2002. november 8. 05:45 dátummal Chris Smith ezt írta:
| 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:
| >
| > exec("cp $pic $File");
|
| Use the move_uploaded_image function in PHP. Safer and easier.
The proper name of the function mentioned here is move_uploaded_file().
See: http://php.net/move_uploaded_file
Snippet from the PHP Manual on how to writing BLOBs into PostgreSQL
databases:
<?php
$database = pg_connect ("dbname=jacarta");
pg_query ($database, "begin");
$oid = pg_lo_create ($database);
echo "$oid\n";
$handle = pg_lo_open ($database, $oid, "w");
echo "$handle\n";
pg_lo_write ($handle, "large object data");
pg_lo_close ($handle);
pg_query ($database, "commit");
?>
--
Papp, Győző
- pgerzson@freestart.hu
^ permalink raw reply [nested|flat] 3+ messages in thread
end of thread, other threads:[~2002-11-11 23:38 UTC | newest]
Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2002-11-08 04:32 Are these steps correct and standard way to upload images into a table? Zhidian Du <duzhidian@hotmail.com>
2002-11-08 04:45 ` Re: Are these steps correct and standard way to upload Chris Smith <csmith@squiz.net>
2002-11-11 23:38 ` Re: Are these steps correct and standard way to upload Papp Gyozo <pgerzson@freestart.hu>
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox