1

I'm just starting to work with Django-Multiupload.

I have a problem - when I try to upload file/files, it seems that it works but no file is being uploaded in fact.

VIEWS.PY

def index(request): multiple_file_upload_form = MultipleFileUploadForm() if request.method == 'POST': print request.FILES return render(request,'index.html', context={'file_upload_form':multiple_file_upload_form}) 

INDEX.HTML

<form action="" method="post"> {% csrf_token %} {{ multiple_file_upload_form | crispy }} <input type="submit" value="submit"> </form> 

FORMS.PY

class MultipleFileUploadForm(forms.Form): attachments = MultiFileField(min_num=1) 

After choosing some file from my PC and clicking on submit, there is <MultiValueDict: {}> in cmd.

Do you know why?

EDIT:

After changing view code:

if request.method == 'POST': if multiple_file_upload_form.is_valid(): print 'ok' print request.FILES else: print multiple_file_upload_form.errors 

It print's that field attachements is required. But I've fill it (file has been chosen).

1 Answer 1

2

Include enctype in your form: http://www.w3schools.com/tags/att_form_enctype.asp

<form action="" method="post" enctype="multipart/form-data">

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.