title: How to Post JSON data and Zip File using web api?
body: <p>I created a angular project with export feature for able to download output as a .Zip to local computer. </p>
  
  <p>Now, I plan to add a new feature to upload the zip file directly to the server using web API instead to download to local, is it possible on angular? I am thinking to modify my function for download to local and change it to push to external server (but not working).
   Since I am new with angular.</p>
  
  <p>@floc Updated:</p>
  
  <p>Thanks for the guide, so I am created the functions as follow: </p>
  
  <pre><code>private function zip($path, $id)
      {
          $realPath = realpath($path);
          $absolute = $realPath.DIRECTORY_SEPARATOR;
          $ignore   = array(realpath($this-&gt;exportsPath), $realPath);
  
          //delete old zip if it exists
          if (is_file($absolute.$id.'.zip')) {
              unlink($absolute.$id.'.zip');
          }
  
          $zip = new ZipArchive();
          $zip-&gt;open($absolute.$id.'.zip', ZipArchive::CREATE);
  
          $files = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($realPath), \RecursiveIteratorIterator::SELF_FIRST);
  
          foreach ($files as $file)
          {
              $path = $file-&gt;getRealPath();
  
              if ( ! in_array($file-&gt;getRealPath(), $ignore)) {
                  if (is_dir($file))
                  {
                      $zip-&gt;addEmptyDir(str_replace($absolute, '', $path));              
                  }
                  else if (is_file($file))
                  {
                      $zip-&gt;addFromString(str_replace($absolute, '', $path), file_get_contents($file));
                  }
              }
          }
  
          if ($zip-&gt;close()) {
              return $absolute.$id.'.zip';
          }
      } 
  </code></pre>
  
  <p>instead save as zip file I want to that zip file upload using web api in one click. I want to modified it but still no luck for this. :(</p>
  
  <p>Thanks for any help and suggestions.</p>