Wednesday, June 1, 2016

Re: how to upload file with pjango

I suggest redefining the form

class UploadFileForm(forms.Form):
    title = forms.CharField(max_length=50)
    file2 = forms.FileField()
    MAX_FILE_SIZE = forms.CharField(widget=forms.HiddenInput(), initial = 10000) 
    

and in template upload.html you tried this?

<form action="#" enctype="multipart/form-data" method="POST">
    <label> Title </label> {{ form.title }} <br>
    <label>Choose a file to upload:</label> {{ form.file2 }} <br>
    {{ form.MAX_FILE_SIZE }} <!-- hidden -->
    <input type="submit" value="Upload File"/>
</form>




2016-05-31 22:53 GMT-03:00 meInvent bbird <jobmattcon@gmail.com>:
after following the web,

it only run one time first time the function in views.py
but after press button, it do not run post method because console did not show POST.

where is wrong?




On Friday, May 27, 2016 at 9:50:29 PM UTC+8, Wyrven no L2Radamanthys wrote:
Hello,

add enctype="multipart/form-data" param in you html form

see more info




2016-05-27 6:45 GMT-03:00 meInvent bbird <jobma...@gmail.com>:
how to upload file with pjango ?

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com.
To post to this group, send email to django...@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/f68770a9-58ae-4cf3-9893-c8793b192fa1%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--

Ricardo Daniel Quiroga

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/8dbb457f-07b7-4839-aa5b-757348a2b266%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.



--

Ricardo Daniel Quiroga

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAO2-wHb5tHm7AE6m-%2B3DCn86WKm6f%2BipL0y%2B2FAF5scEPaC%3D9A%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment