> Is the value assigned to 'galleryfilename' really supposed to be an open
> file object?  Just based on the name it sounds more like it should be a
> string containing the file name.

Ok. Let's be clear. I have a form with 3 inputs:
input type="text" name="name"
textarea name="annotation"
input type='file' accept='image/jpeg' name='galleryfilename'

And in my test I need to simulate user input of with fields. So as was
written in the manual http://www.djangoproject.com/documentation/testing/,
quote:
...
Submitting files is a special case. To POST a file, you need only
provide the file field name as a key, and a file handle to the file
you wish to upload as a value. For example:
>>> c = Client()
>>> f = open('wishlist.doc')
>>> c.post('/customers/wishes/', {'name': 'fred', 'attachment': f})
>>> f.close()
(The name attachment here is not relevant; use whatever name your file-
processing code expects.)
Note that you should manually close the file after it has been
provided to post().
...

My view processes the /fotogallery/addgallery/ url with the following
way:

name = request.POST['name']
annot = request.POST['annotation']
fname = request.FILES['galleryfilename']['filename']
path = MEDIA_ROOT + "/galleryfoto/" + fname
im = Image.open(StringIO(request.FILES['galleryfilename']['content']))
im.save(path,'JPEG')

Did I miss something?
I'm using django 0.96 official release (not development version)


--~--~---------~--~----~------------~-------~--~----~
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