title: How to write png file to target directory from client side by flask
body: <p>I want to write to file from request.form["file"] but I can't do it.</p>
  
  <p>My contact.html is here.</p>
  
  <p>Client side code is like this...</p>
  
  <pre><code>&lt;form action="contact" method="POST" enctype="multipart/form-data"&gt;
  &lt;input type="file" name="file"&gt;
  &lt;input type="submit" value="submit"&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p>Server side is like this</p>
  
  <pre><code>filestorage = request.files["file"]
  
  print type(_file) #-&gt; &lt;FileStorage: u"__proto.png" ("img/png")&gt;
  
  # I tried below this , but it doesn't work.
  
  f = open("tmp.png","wb")
  f.write(filestorage)
  </code></pre>
  
  <p>I want to write this which is png file to  uploaded file somewhere. Do you have any idea? </p>
  
  <p>Thanks in advance.</p>