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:[EMAIL PROTECTED]

Reply via email to