在fine-uploader中为每个文件添加字段 [英] Add field for each file in fine-uploader

查看:82
本文介绍了在fine-uploader中为每个文件添加字段的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

尝试首次实施Fine-Uploader。

Trying to implement Fine-Uploader for first time.

有什么方法可以为每个文件添加文本字段以供上传?
我希望用户评论每个文件的内容,而不是保存这些信息。

There's a way I can add a text-field for each file pending uploading? I want the user to comment the content of each file and than save these informations.

感谢您的解释。
Dario。

Thanks for explanations. Dario.

推荐答案

如果要在用户界面中表示的每个文件旁边添加输入文本字段(我假设您正在使用FineUploader模式),则可以执行以下操作:

If you want to add an input text field next to each file represented in the UI (I'm assuming you are using FineUploader mode), you can do the following:


  1. 设置 autoUpload 选项设置为false。这似乎很明显,但是我认为无论如何我应该列出它。如果您未将其设置为false,则用户选择文件后将立即上传文件。我猜这不适合您的工作流程。

  1. Set the autoUpload option to false. This seems obvious, but I thought I should list it anyway. If you don't set this to false, files will be uploaded immediately after the user selects them. I'm guessing this would not fit into your workflow.

定义 onSubmitted 回调处理程序。在此处理程序中,您可以使用 id 参数在关联的 getItemByFileId API方法

Define an onSubmitted callback handler. In this handler, you can use the id parameter to get a handler on the associated getItemByFileId API method.

一旦在UI中具有表示文件的元素,就可以在其旁边添加一个输入字段。也许您应该添加一个数据属性或一个CSS类,以便以后将该字段与文件相关联。

Once you have the element that represents the file in the UI, you can add an input field next to it. Perhaps you should add a data attribute or a css class that you can later use to associate this field with the file.

我假设您打算创建一个按钮当用户准备好开始上传所有选定文件时(大概是在他们填写了与这些文件相关联的所有文本字段之后),用户将单击该按钮。因此,您可以在此按钮上添加一个点击处理程序,以调用 uploadStoredFiles API方法

I assume you intend to create a button that a user will click when they are ready to start uploading all selected files, presumably after they have filled out any text fields associated with these files. So, you can add a click handler to this button that calls the uploadStoredFiles API method.

您还需要提供 onUpload 回调处理程序。调用处理程序时(每个文件一次,在上传之前),请从关联的文本字段中获取值,然后使用 setParams API方法将此值与该文件的上载(POST)请求一起发送参数。调用 setParams 时,不要忘记将文件ID作为最后一个参数。

You will also need to contribute an onUpload callback handler. When your handler is invoked (once for each file, before it is uploaded), grab the value from the associated text field and then use the setParams API method to send this value with the upload (POST) request for this file as a parameter. Don't forget to include the file ID as the last parameter when you call setParams.

这篇关于在fine-uploader中为每个文件添加字段的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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