perl-modperl mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Alexei Danchenkov <danchen...@comail.ru>
Subject File upload error
Date Fri, 21 Dec 2001 14:28:48 GMT
Hello, All,
This might be a bit offtopic, but while uploading a file to a server,
all zeros (0x0) are replaced with spaces (0x20). What is wrong with
the following code then or what's wrong with the server configuration?
I am using HTML::Mason with Apache server 1.3.22 under RedHat Linux 6.2
When I am doing the same on the Win32 (local devel machine, no problem
occurs).

# UPLOADING IMAGE
if ( my $upload = $r->upload ) {
  $url = $upload->filename;
  $url =~ s/((?:[^\/\\]*?[\/\\]*?)*)([\w\s\.\[\]]*$)/$2/;
  my $fh = $upload->fh;
  my $buffer = "";
  my $fullpath = $ENV{"DOCUMENT_ROOT"}; # w/o trailing slash
  $fullpath =~ s/docs.*/images\//; # adding missing slash
  my $bytesread = 0;
  if ( sysopen OUTPUT, $fullpath . $url, O_CREAT | O_WRONLY | O_EXCL ) {
    binmode $fh;
    binmode OUTPUT;
    while ( my $bytes = sysread( $fh, $buffer, 65536 ) ) {
      syswrite( OUTPUT, $buffer );
      $bytesread += $bytes;
    }
    close OUTPUT;
  } else { $m->out( "<BR>Couldn't open " . $fullpath . $url ); }
} # END UPLOADING

Alexei
mailto:danchenkov@comail.ru


Mime
View raw message