my $file = $cgi->param('file'); select((select($file), $|=1)[0]); my $tempFile; while(<$file>) { $tempFile .= $_; } close($file); mkdir("/var/www/html/pmuze/upload/$username"); open(LOCAL, ">/var/www/html/pmuze/upload/$username/$fileName") or warn $!; select((select(LOCAL), $|=1)[0]); binmode(LOCAL); print LOCAL $tempFile; close(LOCAL);