file('files'); $file_location = $this->unzipFile($import_file->getPathname()); if(Ninja::isHosted()) CompanyImport::dispatch(auth()->user()->getCompany(), auth()->user(), $file_location, $request->except('files'))->onQueue('himem'); else CompanyImport::dispatch(auth()->user()->getCompany(), auth()->user(), $file_location, $request->except('files')); return response()->json(['message' => 'Processing'], 200); } private function unzipFile($file_contents) { $zip = new ZipArchive(); $archive = $zip->open($file_contents); $filename = pathinfo($file_contents, PATHINFO_FILENAME); $zip->extractTo(public_path("storage/backups/{$filename}")); $zip->close(); $file_location = public_path("storage/backups/$filename/backup.json"); if (! file_exists($file_location)) throw new NonExistingMigrationFile('Backup file does not exist, or is corrupted.'); //$data = file_get_contents($file_location); return $file_location; //unlink($file_contents); //unlink($file_location); //return $data; } }