title: How to upload and save a file using bottle framework
body: <p>HTML:</p>
  
  <pre><code>&lt;form action="/upload" method="post" enctype="multipart/form-data"&gt;
    Category:      &lt;input type="text" name="category" /&gt;
    Select a file: &lt;input type="file" name="upload" /&gt;
    &lt;input type="submit" value="Start upload" /&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p>View:</p>
  
  <pre><code>@route('/upload', method='POST')
  def do_login():
      category   = request.forms.get('category')
      upload     = request.files.get('upload')
      name, ext = os.path.splitext(upload.filename)
      if ext not in ('png','jpg','jpeg'):
          return 'File extension not allowed.'
  
      save_path = get_save_path_for_category(category)
      upload.save(save_path) # appends upload.filename automatically
      return 'OK'
  </code></pre>
  
  <p>I'm trying to do this code but it is not working. What I'm doing wrong?</p>