HTML5的ColdFusion处理<输入类型=“文件"多个=“多个";/&gt; [英] ColdFusion handling of HTML5 &lt;input type=&quot;file&quot; multiple=&quot;multiple&quot; /&gt;

查看:18
本文介绍了HTML5的ColdFusion处理<输入类型=“文件"多个=“多个";/&gt;的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试实现一个 HTML5 输入字段,让用户选择要上传的多个文件.我的表单中有以下内容:

I am trying to implement an HTML5 input field that lets the user select multiple files to upload. I have the following in my form:

<form method="post" enctype="multipart/form-data" action="index.cfm">
    <input type="file" name="Images" id="Images" multiple="multiple" accept="image/jpeg, image/gif, image/png, application/zip" />
    ...

我可以在浏览器中选择多个文件,然后单击上传,但我不确定如何使用 ColdFusion 处理表单发布.我认为以下方法会起作用,但这只会上传我选择的最后一个文件:

I am able to select multiple files in the browser, then click upload, but I'm not sure how to handle the form post with ColdFusion. I thought the following would work, but this only uploads the last file I selected:

<cfloop list="#attributes.Images#" index="Image">
    <cffile
        destination = "#ExpandPath(Trim(request.TempFolder))#"
        filefield = "Images"
        action = "upload"
        nameconflict = "MakeUnique"
        result = "UploadedTempFile"
    >
    <cfoutput>#UploadedTempFile.serverFile#<br /></cfoutput>
</cfloop>

有人可以向我解释如何遍历通过我的一个表单字段提交的所有文件,以便我可以单独处理这些文件吗?

Can someone explain to me how to loop through all the files submitted through my one form field so I can handle the files individually?

推荐答案

更新:从 ColdFusion 9 开始,这是真的.这已在 ColdFusion 10 中得到纠正.

UPDATE: As of ColdFusion 9 this was true. This has been corrected in ColdFusion 10.

结束我们的评论对话:

这对于默认的 ColdFusion 行为是不可能的.cffile 不支持从单个 file 元素处理多个文件上传.我认为有可能回退到 JAVA 来做到这一点,但我不知道如何做到这一点.

This simply isn't possible with default ColdFusion behavior. cffile doesn't support handling multiple file uploads from a single file element. I think it could potentially be possible to fallback to JAVA to do this, but I wouldn't have a clue how to make that happen.

我希望 cffile action="uploadall" 获取所有 HTML5 多文件元素.需要将其归档为 CF10 的 ER :).

I would love cffile action="uploadall" to grab all HTML5 multi-file elements. Will need to file that as an ER for CF10 :).

这篇关于HTML5的ColdFusion处理<输入类型=“文件"多个=“多个";/&gt;的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆