This code works fine in my local xampp apache server. I run the same code in local area network with different ip addressed system. The file cannot open and i cant write it to the expected directory. Kindly do the needful? Thanks in advance.
Am passing the xml file through below code.
#!"C:\xampp\perl\bin\perl.exe"
#!"172.18.5.23:\xampp\perl\bin\perl.exe"
#!\usr\bin\perl -wT
#!perl
use strict;
use warnings;
use CGI;
my $query = new CGI;
print $query->header( "text/html" );
print <<END_HERE;
<html>
<head>
<title>My First CGI Script</title>
</head>
<body bgcolor="#FFFFCC">
<h1>Welcome to Perl CGI</h1>
<form action="/cgi-bin/inputxml.cgi" method="post"
enctype="multipart/form-data">
<p>Files to Upload: <input type="file" name="xml" /></p>
<p><input type="submit" name="Submit" value="Submit Form" /></p>
</form>
</body>
</html>
END_HERE
sending the xml file to the below code.....
#!"C:\xampp\perl\bin\perl.exe"
#!"172.18.5.23:\xampp\perl\bin\perl.exe"
#!\usr\bin\perl -wT
#!perl
use strict;
use CGI;
use Cwd 'abs_path';
use CGI::Carp qw(warningsToBrowser fatalsToBrowser);
use File::Basename;
$CGI::POST_MAX;
my $safe_filename_characters = "a-zA-Z0-9_.-";
my $query = new CGI;
my $cgi = new CGI;
my $file = $cgi->param('xml');
my $lines;
open(DATA,"<$file") or die "Can't open data";
print $query->header ( );
$lines = <DATA>;
close(DATA);
$lines =~s{darling}{CGI}ig;
print $lines;
print abs_path($file);
open(OUT, '>dirname($file)."\\out_".basename($file)');
print OUT $lines;
close(OUT);
print $query->header ( );
print <<END_HERE;
open(DATA,"<$file") or die "Can't open data";becomesopen(DATA,"<$file") or die "Can't open data: $!";. See also perldoc open