Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

ajax upload with cfform

Explorer ,
May 29, 2010 May 29, 2010

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.

753
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
May 29, 2010 May 29, 2010
LATEST

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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources