I'm trying to write a script to automatically upload reports in the form of XML files that I generate at work. The website uses form based file upload. Unfortunately, I've been having quite a few problems with it. Here is the code I'm using:
$request = POST ('http://www.environet.gov.on.ca/dwws-app/DWWSApp?
+cmd=UploadSubmPage.uploadSubm',
Content_Type => 'form-data', Content =>
[
works_id=>'300002167',
lab_id=>'48',
filename=>['260015626-220006440.txt']
]
);
print OutFile $request->as_string;
$response = $ua->request($request, 'output2.html');
and the header it generates:
POST http://www.environet.gov.on.ca/dwws-app/DWWSApp?cmd=UploadSubmPag
+e.uploadSubm
Content-Length: 3059
Content-Type: multipart/form-data; boundary=xYzZY
--xYzZY
Content-Disposition: form-data; name="works_id"
300002167
--xYzZY
Content-Disposition: form-data; name="lab_id"
48
--xYzZY
Content-Disposition: form-data; name="filename"; filename="260015626-2
+20006440.txt"
Content-Length: 2769
Content-Type: text/plain
This seems just dandy to me, however the server spits back an error that says 'Malformed line after disposition: Content-Length 2769'. It would appear that it doesn't like the next line. Why I'm not sure... Any suggestions on a course of action?
Thanks, Tim.