January 13, 2012

XPages fileupload control and mime types

I have a problem uploading an image to a form field using the built in xpages fileuploader control. The form field the image is saved to is configured like explained in this blog post by Mats Knutsen: http://devxpages.blogspot.com/2011/03/display-picture-from-rich-text-field.html . I Also plan to display the image in an xpage using the template described in the blog post, like this (http://server/MyDatabase.nsf/viewunid/docunid/imageField/M2?OpenElement).

I know my fileuploader control points to the correct field in the form, since i can see the image in the document using the Lotus Notes Client after the document is created. However; the picture can not be viewed using "http://server/MyDatabase.nsf/viewunid/docunid/imageField/M2?OpenElement" at this point.

On the other hand, if I delete the field contents (the image) from the document field in the client, go back to the xpage with the fileuploader control, and uploads the image a second time, it works perfectly, and the image can be viewed using the url mentioned above.

This image shows my xpages fileupload control code:

This image displays the field properties of the field in the document the image is saved to the first time the fileuploader is used:

If I then delete the contents of the field in the picture above, and re-enters the document in the xpage, uploading the image once again using the file uploader, everything works fine, and i get the field properties of the document as displayed below:

Does anyone know why my file uploader control does not work the first time i upload the image, but when I edit the document and upload the image a second time, everything seems to be ok?