Skip to content

Additional form fields with file upload #1

Description

@jaivikram

Hi

Thanks for writing this example with Django. How would you change the code if you need to add a 'description' field for each file that you upload. I changed the upload template to have

    <tr class="template-upload{{if error}} ui-state-error{{/if}}">
        <td class="preview"></td>
        <td class="name">${name}</td>
        <td class="size">${sizef}</td>
        {{if error}}
            <td class="error" colspan="2">Error:
                {{if error === 'maxFileSize'}}File is too big
                {{else error === 'minFileSize'}}File is too small
                {{else error === 'acceptFileTypes'}}Filetype not allowed
                {{else error === 'maxNumberOfFiles'}}Max number of files exceeded
                {{else}}${error}
                {{/if}}
            </td>
        {{else}}
            <td><input type="text" name="description"/></td>
            <td class="progress"><div></div></td>
            <td class="start"><button>Start</button></td>
        {{/if}}
        <td class="cancel"><button>Cancel</button></td>
    </tr>

The field renders correctly with each file row but the POST data that reaches the server never contains the additional field.

I read the jquery-file-upload docs and found out about formData but could not figure out how to initialize it with different data for each row (file).

Any help will be appreciated.

Jai

Activity

  1. garmoncheg commented on Sep 1, 2011

    @garmoncheg
    Owner

    I think you have to manually add those data from a table input to AJAX post within some variable for example.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions