This repository was archived by the owner on Aug 12, 2020. It is now read-only.
This repository was archived by the owner on Aug 12, 2020. It is now read-only.
Additional form fields with file upload #3
Closed
Description
Hi
Thanks for writing this example with Django. It works out of the box, but how would you change the code if you need to add a 'description' field for each file that you upload.
I have changed the upload-template in the upload_tags.py file to render the additional text field named 'description':
<tr class="template-upload{{if error}} ui-state-error{{/if}}">
<!-- <td class="name">${name}</td> -->
<!-- <td class="size">${sizef}</td> -->
<td class="preview"></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 class="progress"><div></div></td> -->
<td class="start" style="display:none;" ><button>Start</button></td>
<td class="file_upload_desc"><input type="text" name="description"/></td>\
<td class=""><select name="photo_type"><option>restaurant</option></selec\
t></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
Metadata
Metadata
Assignees
Labels
No labels