I'm trying to use a CGI script to accept and save a file from a program that is using an HTTP POST to send a zip file.
In the MIME section of the HTTP header it looks something like this:
Content-Disposition: form-data; name="el_upload_file_0"; filename="BugReport.zip";\r\n
Content-Type: application/octet-stream\r\n\r\n
In my CGI code I'm using this:
use CGI;
use strict;
my $cgi = CGI->new;
my $upload_file = $cgi->upload('el_upload_file_0');
my $time = time;
my $filename = "/tmp/$time.zip";
open TMP, ">$filename";
binmode TMP;
while (<$upload_file>) {
print TMP $_;
}
close TMP;
The file that keeps getting saved is somehow getting corrupt and is not a valid zip file. The HTTP request is being sent by a C# app and it's possible that it might be sending a corrupt zip file, but I doubt it. Is there anything I can do to troubleshoot further?