title: File Upload With Loopback
body: <p>I created a simple file uploading application with loopbackjs. 
  In the application's client side I used simple HTML and Javascript code, calling a loopback api with an AJAX call:</p>
  
  <pre><code>$('#upload-input').on('change', function () {
  
      var files = $(this).get(0).files;
  
      if (files.length &gt; 0) {
          // One or more files selected, process the file upload
          var form = new FormData();
  
          for (var index = 0; index &lt; files.length; index++) {
  
              var file = files[index];
              form.append('Uploded Files', file, file.name);
          }
  
          $.ajax({
              url: 'api/fileupload/upload',
              type: 'POST',
              data: form,
              processData: false,
              contentType: false,
              success: function (data) {
                  console.log('upload successful!');
              }
          });
      }
  
  });
  </code></pre>
  
  <p>We are not getting files on the server side. On the server side we created a Loopback API, but how can we upload files with this API?</p>
  
  <p>This is my loopback API code:</p>
  
  <pre><code>FileUpload.remoteMethod
  
  (
          'upload', {
              http: {
                  verb: 'post',
              },
              accepts:
              [
                  { arg: 'ctx', type: 'object', http: { source: 'context' } },
                  { arg: 'options', type: 'object', http: { source: 'query' } }
  
              ],
              returns: {
                  arg: 'data',
                  type: 'string',
                  root: true
              }
          }
      );
  
      FileUpload.upload = function (context, options, callback) {
          //context.req.params = 'common';
  
      };
  </code></pre>