CGI.pm is Corrupting Uploaded Picture Files!

Also known as...

My Uploaded Files are Growing!

Examples

The Wrong Way:
  use CGI qw/:standard/;

  my $fh = upload('uploaded_file');
  die "No filehandle!" unless $fh;

  open (OUT,">C:/Temporary/upload.txt") || die "Cannot open: $!";
  
  while (<$fh>) {
     print OUT;
  }
  close OUT;

The Right Way:
  use CGI qw/:standard/;

  my $fh = upload('uploaded_file');
  die "No filehandle!" unless $fh;

  open (OUT,">C:/Temporary/upload.txt") || die "Cannot open: $!";
  binmode OUT;    <<<<look
  
  while (<$fh>) {
     print OUT;
  }
  close OUT;


<< Previous Contents >> Next >>

Lincoln D. Stein, lstein@cshl.org
Cold Spring Harbor Laboratory
Last modified: Sat Jun 19 13:49:13 EDT 1999