in reply to uploaded file is not proper

Hello anonymous,
Try replacing from open() to close() with this snippet:

open(MYFILE, ">$upload_file") || die "Couldn't open upload file: $!\n" +; print MYFILE while (<$fname>); close(MYFILE) || die "Couldn't upload file: $!\n";

This won't give you the file size that you where attempting to assign into $size but 'should' work as far as the upload is concerned. If that works you can then work on getting the size of the file afterwards, this is only to ensure that you can get the upload to work 'at all'.

On matters of security:

I'd *really* add a little foreach loop going through an array of accepted acceptable file extensions (mime types) before the upload section, and then chmod the uploaded file to read only, but that's only IMHO (call me paranoid).

Update: Corrected grammar and added "(mime types)"