[plug] PostgreSQL & web page interface

Lyndon Kroker ljkroker at netvigator.com
Thu Aug 22 17:14:31 WST 2002


Hi Tim,

> I think I will go with php.  It looks like just the thing.  Not too
> hard.  I like that.  One minor wrinkle though- I need to upload/
> download files to/ from the database.  This requires file dialog boxes &
> so on.  Does this mean I am better off developing a small applet with
> Java?

Using PHP you can upload and download files to and from your database without 
too much fuss.  I just wrote a script yesterday that uploads a data file for 
updating a single database column (as opposed to a row).  Most of the 
trickery comes in setting up the html form.

When you upload a file using an html form that is processed by PHP the 
filesize may be limited.  Look for something like this in /etc/php.ini

; Maximum allowed size for uploaded files.
upload_max_filesize = 2M

If you won't be handling file uploads from the public then you could probably 
set this parameter to allow larger uploads.  (Less chance of DOS attacks via 
simultaneous uploads of very large files.)

I will mail you a sample upload form and processing script off-list.

Just a couple of other tidbits that may save you some time.  When you upload 
a file using an html form, PHP will automatically create some variables:

$imagefile  -  this is the name of the file as stored in the temporary 
directory on the server

$imagefile_name  -  name of the file as supplied from the user's machine

$imagefile_size  -  size of the file in bytes

$imagefile_type  -  the mime type (image/png, image/jpg, or whatever)

Here's a mistake I was making that belongs in the "I-am-such-an-idiot!" file. 
 I was desparately trying to access a temp file I had previously uploaded.  
The problem was the file no longer seemed to exist.  These temporary files 
you upload (which PHP assigns funny names to) only stick around for as long 
as the *initial* processing script runs.  As soon as this *first* script is 
done, the file gets deleted.  You will not be able to access the file with 
subsequent scripts.

The rest I'll send off-list.

Cheers,

Lyndon





More information about the plug mailing list