Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

Re^2: Upload form

by JimJx (Beadle)
on Feb 18, 2007 at 18:04 UTC ( [id://600726]=note: print w/replies, xml ) Need Help??


in reply to Re: Upload form
in thread Upload form

Thank you, that worked.

I do appreciate the time, but I am curious about why the contents of the file are returned when I use $input{UPLOAD} and select the file on the form when that field name is UPLOAD.

That is going to drive me nuts until I figure it out.

But again, thank you for taking the time to answer.
Jim

Replies are listed 'Best First'.
Re^3: Upload form
by Joost (Canon) on Feb 18, 2007 at 19:17 UTC
Re^3: Upload form
by zentara (Archbishop) on Feb 19, 2007 at 13:51 UTC
    That is going to drive me nuts until I figure it out.

    My advice is to let it go for now, and just accept CGI.pm's way of doing it. A few years ago, after Perl5 came out, and CGI.pm, there was many posts here concerning the old manual-cgi-parsing, and the general wisdom is always use CGI.pm instead of the old Perl4 style manual input parsing. The question was asked so many times, that when anyone asked a cgi question that used manual parsing, they were answered simply with " use CGI.pm".

    So let it go. There are many tiny details, see manual parsing for an idea of the complexities. So just accept for now, as a definition, "always use CGI.pm". The common complaint about CGI.pm is that it is big and cumbersome, but you can just import the input parsing portion of it.... use CGI qw(:cgi), or check out CPAN for CGI::Simple and CGI::Lite.

    You will run into so many problems with manual parsing that it is a waste of time to learn it. For instance what happens when you have multiple files to upload, or you want to give a different name to the uploaded file on the receive end? Look at this nice example:

    #!/usr/bin/perl use warnings; use strict; use CGI::Simple; my $upload_dir='uploads'; my $q = new CGI::Simple; print $q->header(); my $files = $q->upload(); # number of files uploaded +; my @files = $q->upload(); # names of all uploaded fil +es my $filename = $q->param('upload_file'); # filename of uploaded fil +e my $mime = $q->upload_info($filename,'mime'); # MIME type of uploa +ded file my $size = $q->upload_info($filename,'size'); # size of uploaded f +ile # short and sweet upload my $ok = $q->upload( $q->param('upload_file'),"$upload_dir/$filename") +; print "Uploaded ".$q->param('upload_file')." and wrote it OK!\n" if $o +k; print "total files = $files<br> filenames = @files<br> filename = $filename<br> mimetype= $mime<br> size=$size<br>";

    I'm not really a human, but I play one on earth. Cogito ergo sum a bum
      Good advice, I will accept that, for now. ;-)

      But, I have always been the one that wanted to know things and not jst accept conventional wisdom because "that is the way we do things."

      But, when I have more time, I will probably delve deeper into it just for my own curiousity if for no other reason.

      Thanks,
      Jim

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others having an uproarious good time at the Monastery: (5)
As of 2024-04-25 10:31 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found