hi friends
i am trying to upload an image file but i am getting errors.
code is as follows
def thing_add(request):
if request.method == 'POST':
if 'photo' in request.FILES:
# it aint getting here just skip this section
try:
img = Image.open(StringIO(request.FILES['photo']
['content']))
request.FILES['photo']['dimensions'] = img.size
except:
request.FILES['photo']['error'] = True
new_data = request.POST.copy()
new_data.update(request.FILES)
form = ThingForm(new_data)
if form.is_valid():
clean_data = form.clean_data
t = Thing()
t.name = clean_data['name']
if clean_data['photo']:
photo = clean_data['photo']
t.save_photo_file(photo['filename'], photo['content'])
return HttpResponse('/some/where')
else:
form = ThingForm()
context = Context({'form': form})
return render_to_response('loadfiles.html', context)
with loadfiles having
<form action="/test/" enctype="multipart/form-data" method="post">
i am having an exception
Exception Value: string indices must be integers
at line
t.save_photo_file(photo['filename'], photo['content'])
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---