title: Django, saving image, OSError: cannot identify image file
body: <p><strong>CODE:</strong></p>
  
  <pre><code>if request.is_ajax():
      testpic = TestPic.objects.get(pk=1)
  
      form = TestPicForm(request.POST, request.FILES)
      if form.is_valid():
          from PIL import Image
          from io import BytesIO
  
          data = request.FILES['file']
          data_50 = request.FILES['file']
  
          input_file = BytesIO(data.read())
          image_crop = Image.open(input_file)
          print('print 2')
  
          # Problem starts.
          input_file_50 = BytesIO(data_50.read())
          image_crop_50 = Image.open(input_file_50)
          image_crop = image_crop.crop((1,1,100,100))
          image_crop_50 = image_crop_50.crop((40, 40, 140, 140))
          image_resize = image_crop.resize((300, 300), Image.ANTIALIAS)
          image_resize_50 = image_crop_50.resize((50, 50), Image.ANTIALIAS)
  
          image_file = BytesIO()
          image_resize.save(image_file, 'JPEG')
  
          image_file_50 = BytesIO()
          image_resize_50.save(image_file_50, 'JPEG')
  
          data.file = image_file
          testpic.file = data
  
          data_50.file = image_file_50
          testpic.file_50 = data_50
  
          testpic.save()
          return JsonResponse({'success': 'file_uploaded'})
  
      return JsonResponse({'success': 'failed'})
  </code></pre>
  
  <p>And Traceback is like this:</p>
  
  <pre><code>print 2
  Traceback (most recent call last):
  ... I remove some lines ...
    File "D:\pythonDev\project\upward\chatkaboo\authapp\views.py", line 844, in crop
      image_crop_50 = Image.open(input_file_50)
    File "D:\pythonDev\interpreters\forMultichat\lib\site-packages\PIL\Image.py", line 2590, in open
      % (filename if filename else fp))
  OSError: cannot identify image file &lt;_io.BytesIO object at 0x0000024B40510BF8&gt;
  </code></pre>
  
  <p><strong>Description:</strong></p>
  
  <p>As you can see on above my code's purpose is that saving requested image file.</p>
  
  <p>I tried to find what happened and which line has problem. So <code>print 2</code> was printed, and therefore <code>input_file_50 = BytesIO(data_50.read())</code> line has problem.</p>
  
  <p><strong>Question:</strong></p>
  
  <p>Why this error happened? <code>BytesIO</code> can only deal with just one file at a time? </p>
  
  <p>How can I deal with a file and save it as two or more files?</p>