in reply to Upload a file from a web form
Hope this helps.#!/usr/bin/perl # # Save a file uploaded using a web form # use CGI qw(:standard); # $attach1 = param(attach1); # $fh1 = $$attach1; # # Get the file name without any kind of slash # if($attach1 =~ /\\/){ my @filename_parts = split /\\/,$attach1; my $length = scalar(@filename_parts); $attach1 = $filename_parts[--$length]; } if($attach1 =~ /\//){ my @filename_parts = split /\//,$attach1; my $length = scalar(@filename_parts); $attach1 = $filename_parts[--$length]; } $directory = "/home/uploads"; open(ARQ,">","$directory/$attach1"); while(<$fh1>) { print ARQ "$_"; } close ARQ; exit;
Ron
|
|---|