Uploading Multiple Types of Files using Django Jquery File Upload -


when searching django jquery uploading library, came across one. https://github.com/alem/django-jfu

it seems neat , useful. so, decided give shot , started read demo code. however, highlighted line of code hard understand. in file demo/photos/views.py

class home( generic.templateview ):     template_name = 'base.html'      def get_context_data(self, **kwargs):         context = super( home, self ).get_context_data( **kwargs )         **context['accepted_mime_types'] = ['image/*']**         return context 

if want configure able upload both pictures (.jpg, .png, etc.) , .pdf files. how shall highlighted line modified? guess 1 context['accepted_mime_types'] = ['image/* text/plain']

is correct?

on other hand, photo_upload_form.html shall changed from

{% block js_opts %} sequentialuploads: true, acceptfiletypes: /(\.|\/)(png|gif|jpe?g)$/i {% endblock %} 

to

{% block js_opts %} sequentialuploads: true, acceptfiletypes: /(\.|\/)(png|gif|jpe?g|pdf)$/i {% endblock %} 

i added pdf extension @ end.

in all, not find django documentation explaining possible content_type values such 'json/application', 'image/*', 'text/plain'. other possible values?

'accepted_mime_types' list, can add additional items it:

context['accepted_mime_types'] = ['image/*', 'application/pdf'] 

a list of valid mime types available on iana website. can use wildcard bit after /, although don't want other images.


Comments

Popular posts from this blog

javascript - Chart.js (Radar Chart) different scaleLineColor for each scaleLine -

apache - Error with PHP mail(): Multiple or malformed newlines found in additional_header -

java - Android – MapFragment overlay button shadow, just like MyLocation button -