Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

Upload stuff to server

by tja_ariani (Acolyte)
on Aug 14, 2003 at 07:39 UTC ( [id://283786]=perlquestion: print w/replies, xml ) Need Help??

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

Hi, I am new to Perl so it's still dark out there for me to explore. I have this task to set up a website using CIG that allows people uploading stuff to the server. I heard that I can do it with Apache::Request? Is that true? And can anybody give me suggestion where to start learning the CGI programming that allows me to do that? Thanks

20030818 Edit by jeffa: Changed title from 'perl beginner '

Replies are listed 'Best First'.
Re: Upload stuff to server
by sauoq (Abbot) on Aug 14, 2003 at 07:47 UTC

    Check out Web Programming with Perl, by Ovid. For the time being, I wouldn't worry about mod_perl and the Apache::* modules. You should concern yourself with building a solid foundation in the basics first.

    -sauoq
    "My two cents aren't worth a dime.";
    
Re: Upload stuff to server
by snadra (Scribe) on Aug 14, 2003 at 08:15 UTC
    I hope you are able to write HTML? If so you should start learning Perl and learn to use CGI.pm (wich is the CGI module in Perl).
    Do you know the perldocs?
    You can run them on your commandline.
    For CGI it would be:
    perldoc CGI
    These documents will help you a lot.
    There is also a book wich covers CGI.pm. It is published by O'Reilly, who have many other brilliant books as well, and it is called CGI Programming with Perl, 2nd Edition

    snadra
      Yea I write C and Java, so I have no problem with reading purely Perl language. For the web programming I used ASP and now need to use CGI instead. I looked at the O'Reilly but the book does not seem to have things for uploading file. Do you have some other advice? Thanks
        In my copy of the O'Reilly "CGI programming with Perl", it's pages 97-102...referenced in the index as "uploading files, handling with CGI.pm". I find the index (usually found at the back of the book) particularily helpful when looking up information :)

        Cheers, Ben.

Re: Upload stuff to server
by snadra (Scribe) on Aug 14, 2003 at 10:28 UTC
    When you are uploading a file via an HTML form you can access this file using CGI.pm.
    If you are creating the HTML with CGI as well, the upload field can be created like this:
    print $query->filefield(-name=>'uploaded_file', -default=>'starting value', -size=>50, -maxlength=>80);
    Usually these files are uploaded into a temoporary directory. CGI.pm deletes them automatically from the tmp dir after processing.
    Access the file like this:
    $filename = $query->param('uploaded_file'); $type = $query->uploadInfo($filename)->{'Content-Type'}; # or $fh = $query->upload('uploaded_file'); while (<$fh>) { print; }

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others romping around the Monastery: (8)
As of 2024-04-24 17:15 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found