slloyd has asked for the wisdom of the Perl Monks concerning the following question:
#!/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
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Remove Extra bytes at end of file
by wojtyk (Friar) on Sep 08, 2006 at 15:41 UTC | |
|
Re: Remove Extra bytes at end of file
by jdtoronto (Prior) on Sep 08, 2006 at 15:55 UTC | |
|
Re: Remove Extra bytes at end of file
by ikegami (Patriarch) on Sep 08, 2006 at 17:49 UTC | |
|
Re: Remove Extra bytes at end of file
by BrowserUk (Patriarch) on Sep 08, 2006 at 17:19 UTC |