--- fliptop <[EMAIL PROTECTED]> wrote:
> Hytham Shehab wrote:
> >
> > hi gurus,
> > i use the upload() function in the CGI module to get a file in the
> > filefield tag, but i don't understand how to get it to the server?
> > $fh=$q->upload('file_to_be_uploaded');
> > while(<$fh>){
> > print;
> > }
>
> you need to tell perl to print the uploaded file to a file on the hard
> drive:
[ snip ]
Not true. Printing the file contents directly to the screen is a common method of
testing whether
or not the file upload was successful and has nothing to do with whether or not Hytham
was
properly uploading the file.
> don't forget that the file upload will fail if you try to overwrite a
> file that already exists.
I'm not sure what you mean here. CGI.pm creates random names for the uploaded files,
so you can
try to upload the same file five times and you shouldn't have a problem.
> also notice this code assumes $fh is a valid
> filehandle (ie.- there's no code there to handle the case when it
> isn't).
Good point. Here's some code straight from the docs:
$file = $query->upload('uploaded_file');
if (!$file && $query->cgi_error) {
print $query->header(-status=>$query->cgi_error);
exit 0;
}
Cheers,
Curtis Poe
=====
Senior Programmer
Onsite! Technology (http://www.onsitetech.com/)
"Ovid" on http://www.perlmonks.org/
__________________________________________________
Do You Yahoo!?
Get personalized email addresses from Yahoo! Mail
http://personal.mail.yahoo.com/