title: How send post file (image) in python 3
body: <p>first excuse me for my bad english (i speak spanish).</p>
  
  <p>I am trying submit a form uploading with an image.</p>
  
  <p>When i want send normal data (how text string) i do this:</p>
  
  <p>First import modules:</p>
  
  <pre><code>import urllib.request
  
  import urllib.parse
  
  import http.cookiejar
  </code></pre>
  
  <p>Preparing cookies and headers:</p>
  
  <pre><code>cj = http.cookiejar.CookieJar()
  open = urllib.request.build_opener(urllib.request.HTTPCookieProcessor(cj))
  abriendo.addheaders = [("User-agent","Mozilla/5.0")]
  urllib.request.install_opener(open)
  </code></pre>
  
  <p>Encode the url data, i use the id (it is in the web form html )</p>
  
  <pre><code>valor1 = {"username":"test1","password","hello"}
  valor2 = urllib.parse.urlencode(valor1)
  finalvalor = valor2.encode("UTF-8")
  </code></pre>
  
  <p>Now can send post data (remember, this is an example with string data)</p>
  
  <pre><code>nav = urllib.request.urlopen(url,finalvalor)
  navread = str(nav.read())
  </code></pre>
  
  <p>Url variable have the post url</p>
  
  <p>This work good, but i have problems to send a image.</p>
  
  <p>The web form start with this code:</p>
  
  <pre><code> &lt;form enctype="multipart/form-data" onsubmit="return ver('espera');"
            action="example.php" method="post"&gt;
      &lt;input type="hidden" name="MAX_FILE_SIZE" value="5300000"&gt;
              &lt;br&gt;&lt;br&gt;
              &lt;div align="center" id="uploadFileContainer"&gt;
                  &lt;input size="25" id="uploadFile1" name="uploadFile1" type="file"&gt;
  </code></pre>
  
  <p>I do</p>
  
  <pre><code>dicc = {"uploadFile1":open("1.jpg","rb")}
  nav = urllib.request.urlopen(url,dicc)
  navread = str(nav.read())
  </code></pre>
  
  <p>Have this Error:</p>
  
  <pre><code>ValueError: Content-Length should be specified for iterable data of type &lt;class 'dict'&gt; {'uploadFile1': &lt;_io.BufferedReader name='1.jpg'&gt;
  </code></pre>
  
  <p>I try to encode the data ( enconde dicc how normal url ) but not work (do not send any data). I surfed in googe and i think that binary data need to encode to base64 ??</p>
  
  <p>Finally, the question is, how can upload a image with urllib.request module?</p>
  
  <p>Thanks for read.</p>