in reply to open file using variable passed by form
The cgi script folder is normally not writeable to by the web server for security. Try adding
to your script to see what is causing the internal erroruse CGI::Carp 'fatalsToBrowser'; # use only while debugging
or try this SSCCE which writes to /tmp
poj#!/usr/bin/perl use strict; use warnings; use CGI qw/:standard/; use CGI::Carp 'fatalsToBrowser'; # use only while debugging use Cwd; my $cwd = getcwd(); # current working directory my $event = param('event') || 1; my $newCOMMENT = param('newCOMMENT') || 'test comment'; my $commentUID = time(); my $path = '/tmp'; my $fileA = "$path/$event.txt"; my $fileB = "$path/$commentUID.txt"; if ($newCOMMENT ne "") { open AFH, '>>', $fileA or die "Could not open $fileA : $!"; print AFH "$commentUID\n"; close AFH; open BFH, '>>', $fileB or die "Could not open $fileB : $!"; print BFH "$newCOMMENT\n"; close BFH ; } print header,start_html; print pre(" cwd : $cwd event : [$event] newCOMMENT : [$newCOMMENT] commentUID : $commentUID"); print end_html;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: open file using variable passed by form
by haukex (Archbishop) on Mar 17, 2018 at 10:04 UTC | |
by poj (Abbot) on Mar 17, 2018 at 10:26 UTC | |
|
Re^2: open file using variable passed by form
by michael.kitchen (Novice) on Mar 19, 2018 at 05:01 UTC | |
by haukex (Archbishop) on Mar 19, 2018 at 08:27 UTC |