fine-uploader generate more unique custom file ids

梦想的初衷 提交于 2019-12-13 04:42:28

问题


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

but like:

qq-file-id-ahGklm

is there any way to achieve this?

Thank you


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.

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.


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.


回答1:


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.

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.

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.



来源:https://stackoverflow.com/questions/20468195/fine-uploader-generate-more-unique-custom-file-ids

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!