#!/usr/bin/perl #use strict; use CGI qw/:standard/; use Digest::MD5 qw(md5 md5_hex md5_base64); print header(); my $file = param('file'); if (!$file) { #file does not exist print "Error: No file to upload"; return; } #Ignore all but cab files my $fname=$file; if($fname !~/\.cab$/is){ print "Error: Not a cab file"; return; } my $time=time(); my $data=''; while (<$file>) { $data .= $_; } my $md5=md5_hex($data); my $filename="ufiles/$md5\_" . $fname; if(open(FH,">$filename")){ binmode(FH); print FH $data; close(FH); #print the MD5 hash as a return value on success print $md5; } else{ print "Failed to upload file"; }
-------------------------------
Perl - Regularly Expression yourlself
http://www.basgetti.com
In reply to Remove Extra bytes at end of file by slloyd
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |