in reply to Re: Re: CGI Uploading (repost)
in thread CGI Uploading (repost)

$filename comes from just a few lines earlier in the documentation. Of course, a few lines later, the docs suggest this code instead:

use CGI; my $query = CGI->new(); my $fh = $query->upload('uploaded_file'); while (<$fh>) { print; }

Assuming you've created a form that posts to the script correctly, uses the POST method, uses multipart/form-data encoding, and contains a file upload field named uploaded_file, this will work for you.

Replies are listed 'Best First'.
Re: Re: Re: Re: CGI Uploading (repost)
by Anonymous Monk on Apr 17, 2003 at 06:26 UTC
    Ok, with your example... $fh is actually the name of the file it's going to be saved as on the server, right? So doing a while (<$fh>) it's opening up a blank file then saving the contents stored in the buffer? Sorry, I just don't understand how the uploading actually works. I always imagined it upload the file directly from their system, but it looks like that's not the case.

    Other question..Can I set $fh to $fh = param('uploaded_file') or would that be something different?