File uploading is explained in detail at
http://docs.djangoproject.com/en/dev/topics/http/file-uploads/
In short you create a form consisting of a file field:

class UploadFileForm(forms.Form):
    title = forms.CharField(max_length=50)
    file  = forms.FileField()


then write a view function to save it:

def upload_file(request):
    if request.method == 'POST':
        form = UploadFileForm(request.POST, request.FILES)
        if form.is_valid():
            f = request.FILES['file']
            destination = open('some/file/name.txt', 'wb+')
            for chunk in f.chunks():
                destination.write(chunk)
            destination.close()
...

Hope this helps.



On Dec 9, 11:30 am, Vicky <[EMAIL PROTECTED]> wrote:
> If we send a file by post method to a django function how can we
> separate the file from the request?
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to