The dead simple Django download file does not work: - ((

I am desperately trying to make a very simple file upload using Django, without (at the moment) worrying about templates and co.

My HTML:

 <form 
      id="uploader" 
      action="bytes/"
      enctype="multipart/form-data" 
      method="post"
  >
      <input type="file" name="uploaded"/>
      <input type="submit" value="upload"/>
  </form>

My Python (knowing that this is POST):

if path=="bytes/":
        if 'uploaded' in request.FILES:
            return HttpResponse("you uploaded a file")
        else:
            return HttpResponse("did not get the file")

I don’t understand why I always get the message “did not receive the file” ...

Can someone help me please ???

+5
source share
1 answer

Try changing " if 'uploaded' in request.FILES:" to " if request.FILES".

Maybe you should take a look at the documentation; there is an example - http://docs.djangoproject.com/en/dev/topics/http/file-uploads/

+6
source

All Articles