develooper Front page | perl.beginners | Postings from February 2009

Type and Size of the uploaded file

From:
Gunnar Hjalmarsson
Date:
February 26, 2009 09:03
Subject:
Type and Size of the uploaded file
Message ID:
49A6CBB4.9090006@gunnar.cc
[ Please reply to the beginners list - I don't answer questions privately. ]

Prasath wrote (to me privately):
> I am new in perl, i have to find the type and size of the uploaded 
> file in perl. Send me the syntax to find

With CGI::UploadEasy you can do:

     use CGI::UploadEasy;
     my $ue = CGI::UploadEasy->new(-uploaddir => '/path/to/upload/dir');
     my $info = $ue->fileinfo;
     my $cgi = $ue->cgiobject;
     print $cgi->header('text/plain');
     foreach my $file ( keys %$info ) {
         print "File name: $file\n",
               "\tMIME type: $info->{$file}{mimetype}\n",
               "\tSize: $info->{$file}{bytes}\n\n";
     }

Please see http://search.cpan.org/perldoc?CGI::UploadEasy for further 
guidance.

-- 
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl



nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About