$mode = 0644; # take form data my $remotefile = param('upload'); # make new variable to prevent overwriting of form data my $filename = $remotefile; # remove all directories in the file name path $filename =~ s/^.*[\\\/]//; # full file path to upload directory (must include filename) my $localfile = "/home/sulfericacid/public_html/upload/files/$filename"; # open a new file and transfer bit by bit from what's in the buffer open (SAVED,">>$localfile") || die $!; while ($bytesread=read($remotefile,$buffer,1024)) { chmod $mode, '$filename'; print SAVED $buffer; } close SAVED;