views:

187

answers:

2

Hello, I'm using the following JQUERY Plug-in to upload ideas:

http://valums.com/ajax-upload/

For some reason I'm getting the following error:

The cffile action="upload" requires forms to use enctype="multipart/form-data".

Even though the plug-in code has it:

var form = qq.toElement('<form method="post" enctype="multipart/form-data"></form>');

Any ideas what the issue could be?

A: 

Did you intentionally leave out the action tag? Perhaps you can show the CFM handling the file upload as well.

Kyle
It's not the action, I can see it in Firebug, the plugin for some reason isn't posting as a enctype="multipart/form-data" form. It does in the old version?
WozPoz
+4  A: 

It happens because Safari4 and Chrome5 doesn't allow to format xhr request the same way as normal form based upload.

You will need to get the raw post data and write it to the file, when normal way of getting the file is not available.

and return {"success":true}

or in case of error {"error":"error message to display"}

There is a function in Coldfusion called GetHttpRequestData which may help, but I'm not sure, since I never used Coldfusion myself.

http://www.adobe.com/livedocs/coldfusion/7/htmldocs/wwhelp/wwhimpl/common/html/wwhelp.htm?context=ColdFusion_Documentation&amp;file=00000482.htm


If this will be too difficult, I'm planning to add an option to send a file similar way as the previous versions did, but this works perfectly only in Safari5, Chrome6 and latest FF, the users of other browsers will have the same experience as the IE users.

Meanwhile you can use the previous version http://github.com/valums/ajax-upload

valums
@valums - I can confirm your suggestion of using getHttpRequestData(). getHttpRequestData().content returns the file bytes and the URL.qqFile variable contains the file name. You can then save the file to disk using FileWrite(). But I'm curious .. does this apply to FF as well? I noticed the same behavior with 3.6.7.
Leigh
Yes, the file is sent this way in FF3.6+, Safari4+ and Chrome 5+.
valums
Thanks @valums. +1 for the good explanation.
Leigh
One additional note. I had success with most of my browsers (IE,FF,Opera,Chrome). But not with Safari 4.0.2 (windows). If my packet sniffer is to be believed .. the Content-Type sent ends up being "application/x-www-form-urlencoded". This causes the CF server to choke and throw an http 500 error. It seems like something is getting garbled somewhere .. ?
Leigh