Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

file upload problem

Status
Not open for further replies.

altaratz

ISP
Apr 15, 2001
73
US
I'm using the following code to have users upload files to a directory on my site - every time I test though the process adds about 20-30 bits of data to the file, causing havoc with it - like turning this:

(size: 7951 bits)

into this:

(size: 7981 bits)

Any ideas? - Here's the code:

#!/usr/bin/perl

use CGI;
$upload_dir = "/uploads";

$query = new CGI;

$filename = $query->param('upload_file');
$filename =~ s/.*[\/\\](.*)/$1/;
$upload_filehandle = $query->upload("upload_file");

open UPLOADFILE, ">$upload_dir/$filename";

while ( <$upload_filehandle> )
{
print UPLOADFILE;
}

close UPLOADFILE;

print $query->header ( );
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top