fine-uploader生成更多唯一的自定义文件ID [英] fine-uploader generate more unique custom file ids

查看:89
本文介绍了fine-uploader生成更多唯一的自定义文件ID的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将默认文件ID(例如0、1、2,..)更改为更独特的名称,但是我没有成功.由于用户界面的原因,我需要创建文件列表,而不是这样:

I am trying to change the default file ids (e.g. 0,1,2,..) to something more unique, but I haven't succeeded. Due to UI purposes, I need to create files list not like:

qq-file-id-1

qq-file-id-1

但喜欢:

qq-file-id-ahGklm

qq-file-id-ahGklm

有什么办法可以做到这一点?

is there any way to achieve this?

谢谢

我的用户界面分为两部分: 1)用户可以在其中添加缩略图并使用缩略图的模式窗口,在上传之前可以查看其所有文件.有一个上传"按钮. 2)第二个容器(模态之外),用户可以在其中查看每个文件的上传进度.

My UI has 2 parts: 1) A modal window where the user adds files and using thumbnails is able to see all his files before uploading. There is the "upload" button. 2) A second container (outside the modal) where the user sees the uploading progress of each file.

此方案非常完美!上传之前,我从模态获取html(使用jquery)并将其放入第二个容器. 当用户再次选择新文件时,上传时会出现问题.由于Fine Uploader的功能,当我(使用新文件)更新第二个容器时,由于文件ID重复,UI进度状态发生冲突.我试图修改代码,但对我来说太复杂了.

This scenario works perfect! Before uploading I am getting the html (using jquery) from the modal and put it into the second container. The problem appears while uploading, when the user selects again new files. Due to the Fine Uploader's functionality, when I update (with the new files) the second container, the UI progress status conflicts due to duplicates file ids. I tried to modify the code but it was too complicated for me.

谢谢马克的回应! 当前,模态包含帮助用户添加和删除文件的模板(文件列表和按钮).在此区域下面,我将放置一个上载"按钮.当用户单击此按钮时,我(使用jquery)将特定区域剪切-粘贴"到模态之外的另一个div中.一切正常,直到用户将新文件添加到模式中.如果上传队列(放置在与模式不同的div上)包含3个文件,用户从模态甚至1个文件中添加,新文件(qq-file-id-1)的进度与第一个排队文件的进度冲突.

Thank you Mark for your response! Currently, the modal contains the template (files list & button) that helps the users to add and remove files. Bellow this area I am placing a "upload" button. When the user clicks on this button, I "cut-paste" (using jquery) the specific area into another div outside the modal. Everything works fine, until the user adds new files to modal. If the uploading queue (placed on a different div from modal) contains e.g. 3 files and the user adds from modal even 1 file, the progress of the new file (qq-file-id-1) conflicts with the progress of the first queued file.

推荐答案

您看到的数字ID(0、1、2,...)是Fine Uploader内部文件列表(数组)中文件的索引. .显然,每次添加文件时,此数字都会增加.

The numerical ids you are seeing (0, 1, 2, ...) are the indexes of the files in Fine Uploader's internal file list (an Array). Every time a file is added, obviously, this number is incremented.

没有可以覆盖的函数来更改此功能.实际上,您必须重写Fine Uploader内部代码的相当一部分.无论哪种方式,这些都不是您检索文件所要依靠的数字.您应该在某些时候依靠回调和getFile方法来检索文件.

There is not a function you could override to change this. In fact, you'd have to rewrite a considerable portion of Fine Uploader's internal code. Either way, these aren't numbers that you should be relying on to retrieve your file. You should be relying on the callbacks and the getFile method to retrieve your file(s) at certain times.

您可以做的是更改您的模板,以便更改文件列表和上载按钮是最初隐藏的模式窗口的一部分.当用户触发模式窗口时,它将出现,用户可以随意添加和删除文件.窗口关闭时,用户可以按上载按钮(仍是Fine Uploader模板的一部分,但未隐藏)以开始上载.请注意, autoUpload 必须为false,而您必须将事件处理程序添加到上传按钮.

What you could do is change your template so the file list and upload buttons are part of the modal window that was originally hidden. When the user triggers the modal window it appears and the user can add and remove files at will. When the window closes, the user can press the upload button (still part of Fine Uploader's template, but not hidden) to start the upload. Note that autoUpload would have to be false and you would have to add an event handler to the upload button.

这篇关于fine-uploader生成更多唯一的自定义文件ID的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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