Armida
Armida

Reputation: 65

Perl-Not allowed to load local resource

What i am trying to do is to write into a text file. But when i click submit button console shows the error: Not allowed to load local resource: file:///C:/xampp/cgi-bin/test.pl

#!"C:\xampp\perl\bin\perl.exe"

use strict;
use warnings;
use CGI;
use CGI::Carp qw(fatalsToBrowser);

my $cgi = CGI->new;

print $cgi->header,
      $cgi->start_html,
      $cgi->start_form(-action=>'C:\xampp\cgi-bin\test.pl'),
      $cgi->textfield(-name=>'myString'),
      $cgi->submit,

      $cgi->end_form,

      $cgi->end_html;

test.pl

#!"C:\xampp\perl\bin\perl.exe"
# print "Content-type: text/html; charset=iso-8859-1\n\n";

use strict;
use warnings;
use CGI;
use CGI::Carp qw(fatalsToBrowser);

my $cgi    = CGI->new;
my $string = $cgi->param("myString");

print $cgi->header,
      $cgi->start_html('Writing to a file');

open my $fh, '>', './write.txt' or die "failed to open './write.txt' $!";
print $fh $string;
close $fh;

print $cgi->p( "qq(write.txt should contain ".$string.") ");
print $cgi->end_html;

what may be the problem? test.pl is "C:\xampp\cgi-bin\test.pl"

Upvotes: 0

Views: 203

Answers (1)

Quentin
Quentin

Reputation: 944081

$cgi->start_form(-action=>'C:\xampp\cgi-bin\test.pl'),

You need to access the script through your web server. You must give an HTTP URL.

Upvotes: 3

Related Questions