在使用SWFUpload上传之前更改文件名 [英] Change file names before uploading with SWFUpload
问题描述
我正在使用SWFUpload允许用户在任何浏览器中上传多个文件.用户可以为要上传的文件提供自定义文件名.在上载文件之前,如何遍历所有排队的文件并将文件名更新为自定义名称.
I am using SWFUpload to allow users to upload multiple files in any browser. A user can provide custom file names for the files being uploaded. How can I iterate through all the queued files and update the name of the file to the custom name before the file is uploaded.
如果无法更改文件名,如何在要上传的每个文件上添加一个post参数,以在服务器端进行更改?我知道如何为所有文件添加参数,但是如何为每个文件添加参数?
If I can't change the file name, how do I add a post parameter to each file being uploaded to make the change on the server side? I know how to add parameters for all files but how would I do it for each file?
推荐答案
您无法更新在文件上传的POST正文中发送的文件的实际名称,因为SWFUpload在内部使用的是FileReference,不能让您在上传文件之前更改文件的任何属性(而且如果不使用FileReference进行上传就无法获得正确的上传进度,因此这是无法真正更改的东西.)
You can't update the actual name of the file that gets sent in the POST body of the file upload because internally, SWFUpload is using a FileReference which doesn't let you change any of the file's properties before uploading it (and there's no way to get proper upload progress without using a FileReference to do the uploading, so this isn't something that can really be changed).
但是,您应该可以通过 addFileParam
函数为每个文件添加一个额外的POST参数.它的签名是:
However, you should be able to add an extra POST parameter per file via the addFileParam
function. Its signature is:
addFileParam(file_id:String, name:String, value:String):Boolean
这篇关于在使用SWFUpload上传之前更改文件名的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!