views:

1806

answers:

1

Hello,

I am trying desperately to do a very simple file upload with Django, without (for now) bothering with templating & co.

My HTML is:

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

My Python is (knowing it is a 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'm always getting the "did not get the file" message...

Can anyone help me, please???

+6  A: 

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

You might want to take a look at the documentation as well; there's an example-- http://docs.djangoproject.com/en/dev/topics/http/file-uploads/

sysrqb
Sysrqb, I tried but the result is the same!I saw the example you mentioned but I would like not to use all the templating/forms stuff, just a dead simple form.Do you or anyone else know what sucks in my little code snippets???
That should work. You might want to post more of your code so we can help you better.
Brian Neal