S
Suk
Hi
I am experimenting with a very simple file upload script.
I cannot understand why the script below doesnt work:
My web server log shows:
Modification of a read-only value attempted at /var/apache/cgi-bin/
uploader.cgi line 94.
Line 94 is: while ( <$upload_filehandle> )
Here is the script.....
#/usr/local/bin/perl
#
use strict;
use CGI qwstandard);
our $upload_dir = "/tmp";
our ($upload_file,$success,$successfully_uploaded,$count);
foreach ("new","outstanding","weekly","year") {
if (param("$_") ne "") {
&upload_and_install("$_");
}
}
print header();
print <<END_HTML;
<HTML>
<HEAD>
<TITLE>Thanks!</TITLE>
</HEAD>
<BODY>
<P>Thanks for uploading your file</P>
</BODY>
</HTML>
END_HTML
sub upload_and_install {
my ($filename,$upload_filehandle);
$filename = param($_[0]);
$filename =~ s/.*[\/\\](.*)/$1/;
$upload_filehandle = upload($_[0]);
open UPLOADFILE, ">$upload_dir/$filename";
binmode UPLOADFILE;
while ( <$upload_filehandle> )
{
print UPLOADFILE;
}
close UPLOADFILE;
}
However I try the same script but test each parameter invidually
instead of using the foreach loop, and the script does work: So
replacing the foreach loop with this:
if (param("new") ne "" ) {
&upload_and_install("new");
}
if (param("outstanding") ne "" ) {
&upload_and_install("outstanding");
}
if (param("weekly") ne "" ) {
&upload_and_install("weekly");
}
if (param("year") ne "" ) {
&upload_and_install("year");
}
And then I get no errors... Any ideas anyone?
I am experimenting with a very simple file upload script.
I cannot understand why the script below doesnt work:
My web server log shows:
Modification of a read-only value attempted at /var/apache/cgi-bin/
uploader.cgi line 94.
Line 94 is: while ( <$upload_filehandle> )
Here is the script.....
#/usr/local/bin/perl
#
use strict;
use CGI qwstandard);
our $upload_dir = "/tmp";
our ($upload_file,$success,$successfully_uploaded,$count);
foreach ("new","outstanding","weekly","year") {
if (param("$_") ne "") {
&upload_and_install("$_");
}
}
print header();
print <<END_HTML;
<HTML>
<HEAD>
<TITLE>Thanks!</TITLE>
</HEAD>
<BODY>
<P>Thanks for uploading your file</P>
</BODY>
</HTML>
END_HTML
sub upload_and_install {
my ($filename,$upload_filehandle);
$filename = param($_[0]);
$filename =~ s/.*[\/\\](.*)/$1/;
$upload_filehandle = upload($_[0]);
open UPLOADFILE, ">$upload_dir/$filename";
binmode UPLOADFILE;
while ( <$upload_filehandle> )
{
print UPLOADFILE;
}
close UPLOADFILE;
}
However I try the same script but test each parameter invidually
instead of using the foreach loop, and the script does work: So
replacing the foreach loop with this:
if (param("new") ne "" ) {
&upload_and_install("new");
}
if (param("outstanding") ne "" ) {
&upload_and_install("outstanding");
}
if (param("weekly") ne "" ) {
&upload_and_install("weekly");
}
if (param("year") ne "" ) {
&upload_and_install("year");
}
And then I get no errors... Any ideas anyone?