title: Image upload in Jupyter Notebook using ipywidgets.FileUpload()
body: <p>I have been struggling to upload images into my Jupyter notebook using ipywidgets.FileUpload(), it works ok with text files but with binary files the content is always corrupted. Particularly with images, those are always stored as &quot;data&quot; so keras.preprocessing.image.load_img() is unable to use them. The code I am using is:</p>
  <pre><code>import ipywidgets as widgets
  
  uploader = widgets.FileUpload()
  uploader
  
  for name, file_info in uploader.value.items():
      with open(name, 'wb') as fp:
          fp.write(file_info['content'])
  </code></pre>
  <p>I have tried multiple solutions but <strong>nothing is working with binary files</strong>, any hint or help is well received. My environment is GCP AI Platform Notebooks (JupyterLabs 1.2.16, ipywidgets 7.5.1) and the references I have been using are:</p>
  <ul>
  <li><a href="https://stackoverflow.com/questions/61048103/extracting-text-from-ms-word-document-uploaded-through-fileupload-from-ipywidget/61067801#61067801">Extracting text from MS Word Document uploaded through FileUpload from ipyWidgets in Jupyter Notebook</a></li>
  <li><a href="https://ipywidgets.readthedocs.io/en/latest/examples/Widget%20List.html#File-Upload" rel="nofollow noreferrer">https://ipywidgets.readthedocs.io/en/latest/examples/Widget%20List.html#File-Upload</a></li>
  <li><a href="https://stackoverflow.com/questions/60958518/access-the-content-from-multiple-uploaded-files-from-ipywidgets-fileupload">Access the content from multiple uploaded files from ipywidgets FileUpload</a></li>
  <li><a href="https://github.com/jupyter-widgets/ipywidgets/pull/2258" rel="nofollow noreferrer">https://github.com/jupyter-widgets/ipywidgets/pull/2258</a></li>
  </ul>