Uploading a file using Dojo

I was trying to upload a file using and async request with the dojo.xhrPost call. I kept getting an error from my server script (CFMX 7) saying that the contentType was wrong as it was expecting “application/x-www-form-urlencoded” but it was expecting “multipart/form-data”.

It was then brought to my attention that you cannot upload a file using xhrPost. You have to use either dojo.io.iframe.send() or dojox.xhrMultiPart.

I tried the dojo.iframe.send() approach and it worked just fine. The javascript looks like this:

    method: "post",
    url: "process.cfm",
    handleAs: "html",
    timeout: 3000,
    handle: AddEditCallback,
    form: dojo.byId('myForm')