所以我想使用ajax将文件上传到服务器,因此表单未提交。 Cffile需要filefield属性,但因为没有传递给coldfusion的表单对象不起作用。我可以将用户输入的值存储为javascript中的变量,并将该变量传递给cf.如何使用此变量上传文件?感谢。
修改 通过提交iframe来解决。
答案 0 :(得分:2)
您可以使用cffileupload标记(嵌入Flash小部件进行上传),或通过browser support解释的方法利用XMLHttpRequest级别2(here)。
答案 1 :(得分:0)
您上传图片了吗? 您可以尝试使用javascript上传到canvas标签客户端。
然后ajax发布了画布的base64 png编码内容。
进一步阅读和示例:
How to upload/POST multiple canvas elements
How to convert image into base64 string using javascript
Resizing an image in an HTML5 canvas
Resize image before upload, but upload synchronously (not ajax). Is it possible?
http://coding.pressbin.com/84/File-API-Resize-photo-before-upload/
答案 2 :(得分:0)
将表单提交到隐藏的iframe,并像往常一样处理表单上传。