Hi All,
Really need some help here.
I am using PERL CGI application for uploading files through FTP and its not working. The message that it shows is "Can't open data connection". Only the file that i want to upload is created at the destination with zero bytes.
Well when i do FTP using a client software, it works for that same remote machine and files are uploaded.
This code works well when executed to connect another system in the same network and files are uploaded.
The Code is:
sub fnSaveFile {
my $sDriver = $vars{'driverfname'};
my $sXML = $vars{'xmlfname'};
#print $sDriver;
if ($sDriver eq '' || $sXML eq '') {
fnShowForm();
print "please provide information for the empty fie
+lds to execute";
exit();
}
my $sFile = "C:/MyCreationInPerl/$sDriver";
open(FILE,">$sFile") or die "Can not open file $sDriver";
$sReport1 = 'temp';
print FILE "some information";
close FILE;
my $sFile = "C:/MyCreationInPerl/$sXML";
open(FILE,">$sFile") or die "cannot open file";
print FILE "some information";
close FILE;
my $host = 'xx.xx.xx.xx';
my $ftp = Net::FTP->new($host, Timeout => 300, Debug=>1)
or die "Cannot contact $host: $!";
my $output2 = $ftp->login('xxxx','xxxxxx')
or die "Can't login ($host):" . $ftp->message;
$ftp->pasv();
my $path1 = '/testdata/BatchValidation/driver/';
my $output = $ftp->cwd($path1) or die "cannot change dir
+ectory $path1";
$ftp->ascii();
my $filenameDriver = "C:\\MyCreationInPerl\\$sDriver";
my $output1 = $ftp->put($filenameDriver) or die $ftp->message;
print $output1;
#my $path2 = '/testdata/BatchValidation/xml';
#my $output = $ftp->cwd($path2) or die "cannot change director
+y $path2";
#$ftp->ascii();
#my $filenameXML = "C:\\MyCreationInPerl\\$sXML";
#my $output3 = $ftp->put($filenameXML) or die "cannot put $fil
+enameXML to the destination";
##print $output1;
#Win32::MsgBox ("Files have been transfered");
$ftp->quit;
fnShowFormForExecution();
}
Please someone help me!!
Thanks !!