title: Flask-RESTful - Upload image
body: <p>I was wondering on how do you upload files by creating an API service?</p>
  
  <pre><code>class UploadImage(Resource):
      def post(self, fname):
          file = request.files['file']
          if file:
              # save image
          else:
              # return error
              return {'False'}
  </code></pre>
  
  <p><strong>Route</strong><br></p>
  
  <pre><code>api.add_resource(UploadImage, '/api/uploadimage/&lt;string:fname&gt;')
  </code></pre>
  
  <p>And then the HTML</p>
  
  <pre><code>   &lt;input type="file" name="file"&gt;
  </code></pre>
  
  <p>I have enabled CORS on the server side</p>
  
  <p>I am using angular.js as front-end and <a href="https://github.com/danialfarid/ng-file-upload" rel="noreferrer">ng-upload</a> if that matters, but can use CURL statements too!</p>