Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

handling file uploads.

by Punto (Scribe)
on Jun 16, 2000 at 13:15 UTC ( #18438=perlquestion: print w/replies, xml ) Need Help??

Punto has asked for the wisdom of the Perl Monks concerning the following question:

Hi.. can anyone point me to an example on handling file uploads (on a CGI script)?

Thanks..

Replies are listed 'Best First'.
Re: handling file uploads.
by lhoward (Vicar) on Jun 16, 2000 at 14:31 UTC
    See the CGI modle documentation.
    To be safe, use the upload() function (new in version 2.47). When called with the name of an upload field, upload() returns a filehandle, or undef if the parameter is not a valid filehandle.
    $fh = $query->upload('uploaded_file');
Re: handling file uploads.
by wonko (Pilgrim) on Jun 16, 2000 at 15:32 UTC
    I asked the same thing about a week ago, check that thread uploading a file

    /wonko

      question about the code on that thread: is there any way to find out the name of the file that's being uploaded?

      Thanks..

Re: handling file uploads.
by cbraga (Pilgrim) on Jun 19, 2000 at 06:55 UTC
    The excellent Apache Week has a great feature on publishing data with put, including the full source code of a perl script that handles file uploads. Check it out here.
Re: handling file uploads.
by Punto (Scribe) on Jun 19, 2000 at 06:14 UTC
    Ok, I have this new problem now:

    I use:

    $filename = $query->param('uploaded_file');
    And $filename is always empty. I know the file is being transmitted by the browser because I used netcat to see the request..

    Any ideas? thanks..

      Your input field must be named 'uploaded_file' and you really ought to use the CGI::upload() method instead of CGI::param() there.

      Probably just a typo, happens to me all the time.

      CGI::upload() was added in a newer version of CGI, so you might want to upgrade.

        Your input field must be named 'uploaded_file' and you really ought to use the CGI::upload() method instead of CGI::param() there.

        I know.. but when I use upload() I get "Undefined subroutine CGI::upload".

        Probably just a typo, happens to me all the time.

        I checked the spellig too.. :)

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://18438]
Approved by root
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others rifling through the Monastery: (5)
As of 2022-10-05 21:39 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    My preferred way to holiday/vacation is:











    Results (25 votes). Check out past polls.

    Notices?