akhen wrote:

Hi there

I'm trying to use FileInput widget in a Form:
image = forms.Field(widget=forms.FileInput)

But after a post, I just can get the filename not the data.
form.clean_data['image']

Any ideas ?

Thanks.



I think the best thing is to wait until newforms is more developed and
documented on FileInput, but if you really want you can try to add this
to the place where you process your form:

-------------------------------------
out = ''
if (request.FILES):
   out += '<br>request.FILES:<br>'
   out += '<br><br>filename: ' + request.FILES['myfile']['filename']
   out += '<br><br>content-type: ' +
request.FILES['myfile']['content-type']
   out += '<br><br>content: ' + request.FILES['myfile']['content']

return HttpResponse(out)
-------------------------------------

This code assumes you have called your form filefield "myfile" in the
HTML-code, like this:

<form enctype="multipart/form-data" action="test/" method="post">
   <input type="file" name="myfile">
   <input type="submit" value="OK">
</form>

Try this with a small text file as input only, since the whole file
content will be dumped on the screen. This works for me.

The next step would be for the server to create a new file on the HD
and put the content into it. I haven't tried that myself. If you get
that to work, please show the code.
/Henrik


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Django 
users" group.
To post to this group, send email to [email protected]
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