#!/usr/bin/perl -w # # Perl script to accept file uploads. This script is provided for demonstration # purposes only. # you need to have the CGI module installed. # # Copyright Rad Inks (pvt) 2003 # http://www.radinks.com use CGI; use Carp; sub bye_bye { $mes = shift; print "
$mes
\n"; exit; } print "Content-type: text/html\n\n "; my $cg = new CGI(); # # Files will not be saved if $save_path is left undefined. Please make sure # the path you choose is writable. # my $save_path; print <<__TABLE__; __TABLE__ my $size = $cg->param; for($i=0 ; $i < $size ; $i++) { $file_upload = $cg->param("userfile[$i]"); if($file_upload) { my $fh = $cg->upload("userfile[$i]"); my @name = split('/',$fh); my $filename = $name[$#name]; $fsize =(-s $fh); print "\n"; print ""; if(defined($save_path)) { open (OUTFILE,">>$save_path/$filename"); while(<$fh>) { print OUTFILE $_; } close(OUTFILE); } else { carp 'not saving'; } } } print <<__TABLE__;
Files Uploaded
File Name File size
$filename $fsize

Sample Perl Upload handler provided by Rad Inks

have you seen our Secure FTP Applet or our Multimedia Messaging Solution?

__TABLE__