Cannot use "image.save" on django
Posted
by zjm1126
on Stack Overflow
See other posts from Stack Overflow
or by zjm1126
Published on 2010-04-19T02:10:03Z
Indexed on
2010/04/19
2:13 UTC
Read the original article
Hit count: 354
My error is:
IOError at /mytest/photo/upload/
[Errno 2] No such file or directory: u'/mytest/photo/upload/2.png'
And my view is:
UPLOAD_URL = '/mytest/photo/upload/'
def upload(request):
buf = request.FILES.get('photo', None)
print buf
if buf:
#data = buf.read()
#f = StringIO.StringIO(data)
image = Image.open(buf)
#image = image.convert('RGB')
name = '%s%s' % (UPLOAD_URL, buf.name)
image.save(file(name, 'wb'), 'PNG')
return HttpResponse('ok')
return HttpResponse('no')
And my urls.py is:
urlpatterns = patterns('mytest.views',
url(r'^photo/upload/$','upload',name="")
)
How can I fix this?
© Stack Overflow or respective owner