Here's one for all you perl wizards

Justin Bennett justin.bennett at dynabrade.com
Mon Jun 16 13:18:44 EDT 2003


I'm trying to do a file upload with PERL and CGI. I have a multipart 
form that adds a file and it uploads. The uploaded file (from a windows 
PC) both form IE and Mozilla, had extra blank lines in it. In my 
origional testing I was uploading BMPs, and it was working fine. 
Apparently bmps don't mind extra whitespace, but Jpgs and PDFs are all 
messed up.  If I open the binary file in vi and strip the blank lines 
the file is fine. Any ideas?

# CGI STUFF
use CGI qw/:standard/;
$CGI::POST_MAX        = 2_048 * 1_024;
$upload_dir = "/xxx";
$query = new CGI;
$filename = $query->upload("photo");

-SNIP-

$filename =~ s/.*[\/\\](.*)/$1/;
$upload_filehandle = $query->upload('photo');
open LOCAL, ">$upload_dir/$dir/$filename";
binmode LOCAL;
while(<$upload_filehandle>) {
 print LOCAL;
}
close LOCAL;


-- 
Justin Bennett
Network Administrator
RHCE (Redhat Certified Linux Engineer)
Dynabrade, Inc.
8989 Sheridan Dr.
Clarence, NY 14031
 





More information about the nflug mailing list