0

I'm using Laravel 5.7 and have remote server for uploading files. I'm trying to upload files from application server to remote server using league/flysystem-sftp. Everything works fine for static files but now i want to upload ZIP and unzip on remote server.

For uploading zip I'm using SFTP disk configuration in filesystems.php:

'sftp' => [
    'driver'   => 'sftp',
    'host'     => 'example.com',
    'username' => 'your-username',
    'password' => 'your-password',
    'root'     => 'my/root/path/'

],

Storage::disk('sftp')->putFileAs('zip-files', new File('/path/to/zip'), 'example.zip');

How can i extract now this uploaded ZIP file on remote server without writing SSH commands and try with same packages ?

I'm using ZipArchive too in this project and is there any way to unzip files on remote server using ZipArchive ?

1 Answers1

0

You can use chumper/zipper package to extract zip files.

You can install it using composer:

composer require chumper/zipper

Now use,

$path = public_path('test.zip');
\Zipper::make($path)->extractTo('your_file_name');
alexeydemin
  • 2,672
  • 3
  • 27
  • 26
Atul Sharma
  • 9,397
  • 10
  • 38
  • 65
  • I realise this is oldish now, but when calling the \Zipper::make function, I get the following error: 'PHP Fatal error: Uncaught Error: Call to a member function close() on string'. Do you know what might be causing this? – James Feb 06 '20 at 13:45