the form on website doesn't seem to have worked
-----Original Message----- From: Dubcak, Peter [mailto:[EMAIL PROTECTED] Sent: 02 April 2003 14:28 To: '[EMAIL PROTECTED]' Subject: [Perl-unix-users] HTTP::Request::Common upload file headers 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 ________________________________________________________________________ This e-mail has been scanned for all viruses by Star Internet. The service is powered by MessageLabs. For more information on a proactive anti-virus service working around the clock, around the globe, visit: http://www.star.net.uk ________________________________________________________________________ http://www.musicchoice.co.uk Support Digital Media - Join EDiMA - http://www.edima.org Music Choice Limited (company registration number 2838971) is a company incorporated in England and Wales with its registered office at Fleet House, 57-61 Clerkenwell Road, London EC1M 5LA. ********************************************************************** Information in this email is confidential and may be privileged. It is intended for the addressee only. If you have received it in error, please notify the sender immediately and delete it from your system. You should not otherwise copy it, retransmit it or use or disclose its contents to anyone. This footnote also confirms that this email message has been swept by MIMEsweeper for the presence of computer viruses. www.mimesweeper.com ********************************************************************** ________________________________________________________________________ This e-mail has been scanned for all viruses by Star Internet. The service is powered by MessageLabs. For more information on a proactive anti-virus service working around the clock, around the globe, visit: http://www.star.net.uk ________________________________________________________________________ _______________________________________________ Perl-Unix-Users mailing list [EMAIL PROTECTED] To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs