Remember the article I wrote called Creating In-line Response Documents? It describes how to fake forms like the one you would use to add a comment to this blog.
These fake forms work well, until you try and add a file upload control (FUC) to them. This is a problem I've had to address recently. Here's how:
If you simply add a file upload element to the fake form, using PassThru HTML, you will get an error back from the server:
HTTP Web Server: File Upload Not Allowed Exception
To get round this we add a real Domino-style FUC to the actual form in the backend. Then we preview this form in the browser, view the source and copy the HTML for the Domino-rendered FUC, which will look something like this:
The format is %%File.DBRepID.FormID.$Body.0.???. With the FUC on the real form, you can take this string and paste it in as the name of the PassThru FUC on your fake form. You will then be able to upload files as normal.
But! Not only is this an ugly way of doing it, you then have to wonder what happens when you create new copies of this database. Will it still work? Well, for some strange reason, it seems to, but it's not a chance I'd like to take with my designs. Thankfully, there's another way of doing it.
Dimitris Ilaridis recently told me about a Notes.ini setting that is well documented by IBM. The parameter is:
If you add this parameter then you no longer need a FUC on the real form or for the names to match.
There are a couple of gotchas I've discovered though. Firstly, you obviously need to change the enctype of your fake form to "multipart/form-data" before file uploads are allowed. Secondly, I've found that the FUCs you add need to have name beginning with "%%File". You can have more than one FUC on a form, a sample form might look something like this:
<form name="FUCDomino" action="FUCDomino?createdocument" method="post" enctype="multipart/form-data"> <input type="file" name="%%File.1" /><br /> <input type="file" name="%%File.2" /><br /> <input type="submit" value="Upload" /> </form>
Hope you find this as useful as I have recently.