Ash Singh wrote:

Use this as an example, it converts the file to binary mode just in case its
not.  It also strips out the path of the file coming from the user's local
machine.

#!/usr/bin/perl

use CGI;
use strict;

my $cgi = new CGI; print $cgi->header;
my $query = CGI::new();
use CGI qw(param);

my ($bytesread,$buffer);

my $filename = $query->param('uploaded_file');
my $submit = $query->param('Submit');

#path on the server where the file will be saved
my $path = 'D:\webs\test\UploadFolder';

my $newFileName = $filename;
$newFileName =~ s/^.*(\\|\/)//;      #get file name only (strip path)
my $FiletoWrite = "$path\\$newFileName";


if (defined($filename)) { open (OUTFILE,">$FiletoWrite") || die print "can't create file"; binmode $filename; binmode OUTFILE; while ($bytesread=read($filename,$buffer,1024)) { print OUTFILE "$buffer"; }

 close(OUTFILE);
 $filename = undef;
 $path = undef;
 $newFileName = undef;
 $FiletoWrite = undef;
}



Thank you sir for your help. Evidently to compound matters, the FTP program I was using to check on the success of my uploads had a bug in it as well. However, your script is solid and works swimmingly.


-- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>




Reply via email to