Add field for each file in fine-uploader

2019-09-08 17:43发布

问题:

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.

Thanks for explanations. Dario.

回答1:

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. 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.

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

  3. 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.

  4. 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.

  5. 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.