Skip to main content
Known Participant
May 29, 2010
Question

ajax upload with cfform

  • May 29, 2010
  • 1 reply
  • 795 views

Hi,

I am trying to upload a file with ajax, is there a way to do this using cfajaxproxy or any of the other ajax controls? I usually use uploadify but is not really doing the job in this case.

<cfform>
    
     <h4>Document Title</h4>
     <input name="docTitle" id="linkTitle" />
    
     <h4>Document</h4>
    <input type="file" name="document" id="document" />
    
    
     <a href="javascript:submitDoc()">upload document</a>
</cfform>

Thanks,

H.

    This topic has been closed for replies.

    1 reply

    existdissolve
    Inspiring
    May 30, 2010

    As far as I know, XMLHttpRequest can't handle multipart/formdata, so there's no strictly AJAX way to do it. The CF docs even specify that this is not possible using ajaxproxy's "setform" function:

    "Note: You cannot use the setForm function to submit the contents of file  fields." (ref)

    You can, however, use a hidden iFrame to handle the file uploading, monitor it, and then return the results to your application. I've used this before, and it works well.

    Ray Camden has a pretty good article on this..check it out:

    http://www.coldfusionjedi.com/index.cfm/2008/2/27/Can-you-do-file-uploads-with-ColdFusion-8s-Ajax-features

    Hope this helps--regards