#!D:\perl\bin\perl.exe -T use strict; use warnings; use CGI; use HTML::Entities; use constant UPLDTMPDIR => './newDocs/'; use constant ZIPTEMPFILE => 'zip~tempfile.zip'; $CGI::DISABLE_UPLOAD = 0; # Temporarily reenable uploads $CGI::POST_MAX = 1_048_576; my $cgi = CGI->new; print $cgi->header, $cgi->start_html( -title => "Test" ); get_upload(); print $cgi->h1( "It worked. Stop whining and get this done!" ), $cgi->end_html; sub get_upload { $cgi->cgi_error and error( "Error uploading file: " . $cgi->cgi_error ); my $zipFile = $cgi->upload( "zipfile" ) or error( $cgi->p( "No file uploaded." ) ); my $format = $cgi->uploadInfo( $zipFile )->{ 'Content-Type' }; if ( $format ne 'application/x-zip-compressed' ) { error($cgi->p( "Illegal file format." ) ); } open FH, ">", UPLDTMPDIR.ZIPTEMPFILE or die "Can't open ".UPLDTMPDIR.ZIPTEMPFILE." for writing: $!"; { local $/; binmode $zipFile; print FH <$zipFile>; } close FH or die "Can't close ".UPLDTMPDIR.ZIPTEMPFILE.": $!"; }