I need to generate a post http request that sends to a domino server (from a Solaris box) a bunch of form data including one or more upload files. In other words, I am trying to mimic the behavior of submission of this type of form:
<form method="POST" action="http://domino/appname.nsf/M?CreateDocument" enctype="multipart/form-data"> <input type="text" name="FirstName" value="John"> <input type="text" name="LastName" value="Doe"> <input type="file" name="%%File7cfd40fb9757495b85256cf0007322bb.$Body.0.7128" value="word.doc"> </form> To accomplish this, I wrote: #!/usr/local/bin/perl -w use strict; use CGI; use CGI::Carp qw(fatalsToBrowser); use LWP::UserAgent; use HTTP::Request::Common; use HTTP::Headers; my $q = new CGI; print "Content-type: text/html\n\n"; my $agent = new LWP::UserAgent; $result = $agent->request( POST 'http://domino/appname.nsf/M?CreateDocument', Content_Type => 'form-data', Content => [ FirstName => 'John', LastName => 'Doe', '%%File7cfd40fb9757495b85256cf0007322bb.$Body.0.7128' => ["/web/docroot/word.doc"] ]); print "all is well.\n\n" if $result->is_success; All data posts fine (including the attached file), except that using the html method (the first code fragment), the file is readable in MS Word when downloaded from domino, while using the perl request method, the file comes out as garbage on the domino side. I noticed that there was a header in the garbage-d file that read: Content-Type: application/octet-stream which I'm assuming is the default. I tried to remedy the situation by changing ["/web/docroot/word.doc"] to ["/web/docroot/word.doc","word.doc",'Content-type' => 'application/msword'] in the second code fragment. The transferred file still comes out of domino as garbage though, although the header in the garbage-d file now reads: Content-Type: application/msword I also thought that the wacky domino form field name for the upload file could have something to do with the problem, but the file does get uploaded and associated with the correct record. It seems that there may be other header entries I may need to set in the HTTP::Request::Common object for the upload field to get the encoding or whatever set right for the MS Word doc. Btw, both the perl (5.6.0) script and domino server are running on solaris (SunOS 5.7). Thanks in advance for any comments. Peter ************************************************************************** The information transmitted herewith is sensitive information intended only for use by the individual or entity to which it is addressed. If the reader of this message is not the intended recipient, you are hereby notified that any review, retransmission, dissemination, distribution, copying or other use of, or taking of any action in reliance upon this information is strictly prohibited. If you have received this communication in error, please contact the sender and delete the material from your computer. _______________________________________________ Perl-Unix-Users mailing list [EMAIL PROTECTED] To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs