#!/usr/local/bin/perl use CGI; use CGI::Carp qw/fatalsToBrowser/; print "Content-type:text/html\n\n"; $cgi = new CGI; $dir = "/usr/home/mywebsite/public_html/welcome/graphicsincoming"; $file = $cgi->param('file'); if ($file =~ /.jpeg/gi){ &start; } elsif ($file =~ /.gif/gi){ &start; } elsif ($file =~ /.jpg/gi){ &start; } else{ dienice("Sorry, but you have either not selected a file to upload or you are trying to upload an invalid picture file. Only the following file extensions are supported: /.jpeg/.gif/.jpg. Please press the 'back' button below to return to the Upload form."); } sub start{ open(COUNT,"; chomp(@numbers); close(COUNT); $filename = @numbers[-1]; $filename++; $file_name = "$filename"; $file=~m/^.*(\\|\/)(.*)/; # strip the remote path and keep the filename open(LOCAL, ">$dir/$file_name") or die $!; while(<$file>) { print LOCAL $_; }