When a web page creates a form that contains both variables and an "attached" file, it is encoded using a method known as "multipart/form-data". HTTPAPI has a tool that lets you build a document in multipart/form-data (which I'll refer to as MFD to save typing) by building the MFD file in the IFS.
In your scenario, that would work like this:
1) Create the MFD file on the IFS using HTTPAPI's routines.
2) Add your form fields to it using HTTPAPI's routines.
3) Add the file(s) you wish to attach to it using HTTPAPI's routines.
4) close the MFD File (again with HTTPAPI's routine)
5) Upload the MFD file to the server, just like any other file.
6) Delete the MFD file -- since it was just a temporary object, needed for the file transfer only.
Here's a quick example.. note that this is off the top of my head and untested! But, it should at least point you in the right direction. I tried to add a lot of comments to give you the idea...
ctl-opt dftactgrp(*no) bnddir('HTTPAPI');
dcl-s tempFile varchar(40);
dcl-s form pointer;
dcl-s type char(64);
dcl-s rc int(10);
tempFile = http_tempfile();
form = http_mfd_encoder_open(tempFile: type);
// These would be the "regular" form fields:
http_mfd_encoder_addvar_s(form: 'form-variable-1': 'value');
http_mfd_encoder_addvar_s(form: 'form-variable-2': 'value');
// Here's how you attach a file... this would be your
// PDF file... can be other types, too... but you'll need to
// use the proper content type (instead of application/pdf)
: 'application/pdf' );
// if needed, you can call http_mfd_encoder_addstmf multiple
// times if you want to attach multiple files.
// You now have an MFD encoded file in the IFS containing
// the form field(s) and attachment(s) that you added!
// Also the "type" variable has the type of the form that is
// needed by the server.
// Now you can send the file.
rc = http_url_post_stmf( 'http://your-url'
: type );
// this is the IBM-supplied API to delete an IFS file.
// used here to delete our temporary MFD encoded file.
// handle any errors during post here... etc..
if rc <> 1;
*inlr = *on;
On 2/27/17 2:51 PM, Gerald Magnuson wrote:
_______________________________________________ Ftpapi mailing list Ftpapi@xxxxxxxxxxxxxxxxxxxxxx http://scottklement.com/mailman/listinfo/ftpapi