in reply to Trying to make a simple file uploader CGI script
I don't see you output any headers. So, (part of) the actual body is treated as the headers, required ones (like the content-type) are missing, other lines are not recognized as headers... Of course it gives a server error.