I have a HTTP server (newLISP running on a Linux box), which runs my CGI scripts. It runs on my Linux box.
I have a strange problem with uploading files using the POST method. My CGI script is simple: it reads everything from stdin, and saves it in a file. I wrote the script for debugging purposes: I wanted to know, what exactly is read.
When I upload a text file, everything is fine. I mean I get something like that:
-----------------------------18218802734725416881815749595 Content-Disposition: form-data; name="uploaded_data"; filename="post.gif" Content-Type: image/gif (and here's the content of the text file) -----------------------------18218802734725416881815749595 Content-Disposition: form-data; name="text_field_name" text field value -----------------------------18218802734725416881815749595 Content-Disposition: form-data; name="submit" Upload -----------------------------18218802734725416881815749595--
And that's exactly what I should get, according to the RFC 1867 (Form-based File Upload in HTML). (Yes, I renamed this text file to "post.gif".)
The problem is, I get something really strange, when I try to upload any binary file. For example, when I upload a gif image, I get this:
-----------------------------208529943213031756281593958364 Content-Disposition: form-data; name="uploaded_data"; filename="polsl.gif" Content-Type: image/gif GIF89a_
What can be the cause of this strange behaviour?