ColdFusion处理HTML5< input type =" file" multiple =“multiple” /> [英] ColdFusion handling of HTML5 <input type="file" multiple="multiple" />
问题描述
我想实现一个HTML5输入字段,让用户选择多个文件上传。我有以下形式的:
< form method =postenctype =multipart / form-dataaction =index.cfm>
< input type =filename =Imagesid =Imagesmultiple =multipleaccept =image / jpeg,image / gif,image / png,application / zip/>
...
我可以在浏览器中选择多个文件, ,但我不知道如何处理与ColdFusion的表单。我认为以下会工作,但这只是上传我选择的最后一个文件:
< cfloop list =图片#index =图片>
< cffile
destination =#ExpandPath(Trim(request.TempFolder))#
filefield =Images
action =upload
nameconflict = MakeUnique
result =UploadedTempFile
>
< cfoutput>#UploadedTempFile.serverFile#< br />< / cfoutput>
< / cfloop>
有人可以向我解释如何遍历通过我的一个表单字段提交的所有文件,
:从ColdFusion 9开始,这是真的。因此,为了包装我们的评论对话:
t可能与默认ColdFusion行为。 cffile
不支持从单个文件
元素处理多个文件上传。我认为有可能回到JAVA做这个,但我不会有一个线索如何使这种情况。
我会爱 cffile action =uploadall
来抓取所有HTML5多文件元素。需要将其作为CF10的ER文件:)。
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" />
...
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?
UPDATE: As of ColdFusion 9 this was true. This has been corrected in ColdFusion 10.
So to wrap up our comment conversation:
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.
I would love cffile action="uploadall"
to grab all HTML5 multi-file elements. Will need to file that as an ER for CF10 :).
这篇关于ColdFusion处理HTML5< input type =" file" multiple =“multiple” />的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!