title: How to upload and open a file in xampp apache server using CGI Perl Script?
body: <p>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.</p>
  
  <p>Am passing the xml file through below code.</p>
  
  <pre><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-&gt;header( "text/html" );
  print &lt;&lt;END_HERE;
  
  
   &lt;html&gt;
        &lt;head&gt;
          &lt;title&gt;My First CGI Script&lt;/title&gt;
        &lt;/head&gt;
        &lt;body bgcolor="#FFFFCC"&gt;
          &lt;h1&gt;Welcome to Perl CGI&lt;/h1&gt;
          &lt;form action="/cgi-bin/inputxml.cgi" method="post"
          enctype="multipart/form-data"&gt;
          &lt;p&gt;Files to Upload: &lt;input type="file" name="xml" /&gt;&lt;/p&gt;
          &lt;p&gt;&lt;input type="submit" name="Submit" value="Submit Form" /&gt;&lt;/p&gt;
          &lt;/form&gt;
        &lt;/body&gt;
      &lt;/html&gt;
      END_HERE
  </code></pre>
  
  <p>sending the xml file to the below code.....</p>
  
  <pre><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-&gt;param('xml');
          my $lines;
          open(DATA,"&lt;$file") or die "Can't open data";
          print $query-&gt;header ( );
          $lines = &lt;DATA&gt;;
          close(DATA);
          $lines =~s{darling}{CGI}ig;
          print $lines;
          print abs_path($file);
          open(OUT, '&gt;dirname($file)."\\out_".basename($file)');
          print OUT $lines;
          close(OUT);
  
  
          print $query-&gt;header ( );
      print &lt;&lt;END_HERE;
  </code></pre>