Here, in this tutorial i will share with you example of import zip file data with extract zip file and download files in folder in laravel 5.5 application. in this example we require to use chumper/zipper composer package for import extract zip file.
let's see bellow example:
Install chumper/zipper Composer Package:
first thing is to install composer package in our project. so install chumper/zipper composer package by following composer command in your laravel 5.5 application.
composer require chumper/zipper
After successfully install package, open config/app.php file and add service provider and alias.
config/app.php
'providers' => [
....
'Chumper\Zipper\ZipperServiceProvider'
],
'aliases' => [
....
'Zipper' => 'Chumper\Zipper\Zipper'
]
Example:
Here i created simple example of extract file "Downloads.zip" in my "images" folder of public directory. So you can extract file this way:
routes/web.php
Route::get('/zip', function(){
$logFiles = Zipper::make(public_path('Downloads.zip'))->listFiles();
Zipper::make(public_path('Downloads.zip'))->extractTo(public_path('images'));
dd($logFiles);
});
I hope you found best solution.....
Do you like below Tutorials ?
- PHP Laravel 5.5 - import export data into excel and csv using maatwebsite
- Laravel 7.x and 6.x create custom facade example from scratch
- Node JS - Get Real time online users counter using socket io example
- PHP Laravel 7.x and 6.x - Bootstrap Admin Theme Integration example from scratch
- MySQL Query - How to select records of today to next Sunday ?
- Laravel 7.x and 6.x - username custom validation example
- Laravel 5.5 - Import Extract zip file using chumper/zipper package
- PHP Laravel Set Custom Validation Error Messages Example