N
News sender
Hi there,
I am using CGI and Perl for uploading files. The Perl code is included.
The code works fine on PC and Linux (both run apache 2.0.39). But when I run
the code on Unix (solaris7, also run Apache2.0.39), only the filename is
uploaded, not the contents:
-rw------- 1 nobody nobody 0 Apr 19 16:10 file1
-rw------- 1 nobody nobody 0 Apr 19 16:35 file2
You can see the file names are right: file1, file2. But the size of each
file is 0.
The permission of the directory is set as 777:
drwxrwxrwx 2 nobody nobody 512 Apr 2 15:33 shared
There is no error messages in the Apache log files.
Does anyone see this problem before? Any help is appreciated.
Many thanks.
-----------------------------------------------------------
#!/usr/bin/perl
use CGI;
$query = new CGI;
$filepath = $query->param ('filename');
if ($filepath =~ /([^\/\\]+)$/)
{
$filename="$1";
print "The file name is: ", $filename, "<br>";
}
else
{
$filename="$filepath";
}
# check the existence of the file
if (-e "../htdocs/sharedfiles/$filename")
{
print "A file with the same name exists, please rename your file.",
"<br>";
}
else
{
# open the file and load it
open (OUTFILE,">../htdocs/sharedfiles/$filename ");
binmode(OUTFILE);
while ($bytesread=read($filepath,$buffer,1024)) {
print OUTFILE $buffer;
}
close OUTFILE;
print "Your file has been successfully uploaded.", "<br>";
}
I am using CGI and Perl for uploading files. The Perl code is included.
The code works fine on PC and Linux (both run apache 2.0.39). But when I run
the code on Unix (solaris7, also run Apache2.0.39), only the filename is
uploaded, not the contents:
-rw------- 1 nobody nobody 0 Apr 19 16:10 file1
-rw------- 1 nobody nobody 0 Apr 19 16:35 file2
You can see the file names are right: file1, file2. But the size of each
file is 0.
The permission of the directory is set as 777:
drwxrwxrwx 2 nobody nobody 512 Apr 2 15:33 shared
There is no error messages in the Apache log files.
Does anyone see this problem before? Any help is appreciated.
Many thanks.
-----------------------------------------------------------
#!/usr/bin/perl
use CGI;
$query = new CGI;
$filepath = $query->param ('filename');
if ($filepath =~ /([^\/\\]+)$/)
{
$filename="$1";
print "The file name is: ", $filename, "<br>";
}
else
{
$filename="$filepath";
}
# check the existence of the file
if (-e "../htdocs/sharedfiles/$filename")
{
print "A file with the same name exists, please rename your file.",
"<br>";
}
else
{
# open the file and load it
open (OUTFILE,">../htdocs/sharedfiles/$filename ");
binmode(OUTFILE);
while ($bytesread=read($filepath,$buffer,1024)) {
print OUTFILE $buffer;
}
close OUTFILE;
print "Your file has been successfully uploaded.", "<br>";
}