[Memphis.pm] [Fwd: Re: [GOLUM] CGI: file upload widget processing]
cameron walker
cameronw at informix.com
Wed Mar 15 12:42:08 CST 2000
Now for the next stupid question:
Where do I get the CGI module referred to in the first couple lines? I presume
that's what the 'use' is doing.
> #!/usr/bin/perl -wT
>
> use CGI qw(param);
> use CGI::Carp qw(fatalsToBrowser);
>
> $tmpdir = '/tmp'; # probably a bad idea
>
> if (param('file')) {
> $filename = param('file');
> $filename =~ /(.*[\\\/:])*(.*)/; # put the filename
> # minus the path in $2
> # regex magic makes it work
> # on windows, mac, or unix
> # and makes taint checking happy
> $filesuffix = $2;
> binmode $filename; # needed on Win32 for binary files
> # superflous on a real OS
> open(TMPFILE, ">$tmpdir/$filesuffix") || die "Couldn't open temp
> file: $!";
> binmode TMPFILE; # for Win32
> while (<$filename>) { # automagically created filehandle
> print TMPFILE;
> }
> }
>
> print <<FIN;
> Content-type: text/plain
>
> Done!
> FIN
>
> __END__
>
> In other words, if you "use CGI", any file specified through <INPUT
> TYPE=FILE> will have a filehandle automagically associated with it which
> you can read from.
>
> --
> Brock Sides
> Unix Systems Administration
> Towery Publishing
> bsides at towery.com
>
> ----------------------------------------------------------------------------
> To unsubscribe, please send email to majordomo at pm.org
> with 'unsubscribe memphis-pm-list' in the body of the message.
> ----------------------------------------------------------------------------
----------------------------------------------------------------------------
To unsubscribe, please send email to majordomo at pm.org
with 'unsubscribe memphis-pm-list' in the body of the message.
----------------------------------------------------------------------------
More information about the Memphis-pm
mailing list