help with perl

From: News sender (renping.liu_at_eng.ox.ac.uk)
Date: 04/20/04


Date: Tue, 20 Apr 2004 10:54:30 +0100

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.
-----------------------------------------------------------
#!d:/Perl/bin/Perl.exe

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>";
 }



Relevant Pages

  • help with upload perl
    ... 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). ...
    (comp.lang.perl.misc)
  • CGI.pm and form creation
    ... I'm trying to create a little form usign CGI.pm but I get this error from apache: ... this is my perl code: ... use CGI qw/:standard/; ... sub print_form { ...
    (perl.beginners)
  • Re: dynamic lib ignored even after "found" in "install_driver(Oracle) failed: Cant load..." cgi prob
    ... the solution i found is this: i moved the directory containing libclntsh.so under /usr/lib, which is a location that apache seems to trust, as opposed to where i had originally placed this directory. ... so, if i knew then what i know now, here are the steps _I_ would use were i to install the oracle instantclient such that the DBD::Oracle module would work when used in an apache 2.0 CGI: ... i also could run it this way by placing tnsnames.ora in my home directory as .tnsnames.ora, but this location will do me no good when i want apache to run the script as a cgi. ... am i missing some sort of configuration detail regarding apache and permissions granted a cgi? ...
    (perl.dbi.users)
  • Re: CGIs & CSS - References
    ... my $q = new CGI; ... > If the link tag method is considered to be sufficient, then hey, I'm ... (Naturally the stylesheets and js files are in both ... This makes me think it's Apache. ...
    (perl.beginners)
  • Re: Apache and Perl in Windows
    ... The cgi scripts execute, ... I am studying a spider book that uses Perl so I ... > file in apache and rename the jar files in the server directory. ...
    (comp.lang.perl.misc)