Cannot use "image.save" on django
- by zjm1126
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?