title: Exception occurred processing WSGI script - IOError: failed to write data
body: <p>I'm trying to save an image at the server side.I recieve it as base64 string so I decode it first and then save it in the database.However this failed, so I checked the server error log and I found the following
  error.log</p>
  
  <pre><code>    [Tue May 21 14:26:38 2013] [error] [client 41.236.182.133] mod_wsgi (pid=4952): Exception occurred processing WSGI script '/root/AR_BROWSER/example/wsgi.py'.
  [Tue May 21 14:26:38 2013] [error] [client 41.236.182.133] IOError: failed to write data
  </code></pre>
  
  <p>I checked wsgi.py </p>
  
  <pre><code>import os
  import sys
  
  path = '/root/AR_BROWSER/example'
  
  sys.path.append('/root/AR_BROWSER/example')
  sys.path.append('/root/AR_BROWSER')
  sys.path.append('/root/AR_BROWSER/example/app')
  
  os.environ['DJANGO_SETTINGS_MODULE'] = 'settings'
  
  import django.core.handlers.wsgi
  application = django.core.handlers.wsgi.WSGIHandler()
  </code></pre>
  
  <p>But i can't find something wrong. Any idea what could be the cause of this issue?!
  the code responsible for saving the image</p>
  
  <pre><code> @csrf_exempt    
      def create_app(request):
          appName = request.POST['name']
          user = request.POST['userID']
          c = request.POST['category']
          i = request.POST['image']
          imgdata = base64.b64decode(i)
          t = datetime.now()
          filename = t.strftime('test.jpg')  
          with open(filename, 'w') as f:
              f.write(imgdata)
              f.close()
          u=App_User.objects.get(id=user)
          apps = App.objects.create(name = appName, category=c, user_id = u.id, app_logo=File(filename))
          apps.save()
  
          return HttpResponse("You created %s." % apps.name)
  </code></pre>