Thomas  Granger

Thomas Granger

1569651736

How to Create Zip File and Download in Laravel 6?

In this post, I will show you how to create very simple way to zip file in Laravel 6 application. So let’s follow few things and make it simple example.

Step 1: Create Route

First thing is we put one route in one for download created zip file. So simple add both routes in your route file.

routes/web.php

Route::get('download-zip', 'ZipController@downloadZip');

Step 2: Create Controller

Same things as above for route, here we will add one new method for route. downloadZip() will generate new zip file and download as response, so let’s add bellow:

app/Http/Controllers/ZipController.php

<?php

   

namespace App\Http\Controllers;

   

use Illuminate\Http\Request;

use File;

use ZipArchive;

  

class ZipController extends Controller

{

    /**

     * Display a listing of the resource.

     *

     * @return \Illuminate\Http\Response

     */

    public function downloadZip()

    {

        $zip = new ZipArchive;

   

        $fileName = 'myNewFile.zip';

   

        if ($zip->open(public_path($fileName), ZipArchive::CREATE) === TRUE)

        {

            $files = File::files(public_path('myFiles'));

   

            foreach ($files as $key => $value) {

                $relativeNameInZipFile = basename($value);

                $zip->addFile($value, $relativeNameInZipFile);

            }

             

            $zip->close();

        }

    

        return response()->download(public_path($fileName));

    }

}

Ok now you can run project and open that route like.

But make sure you have “myFiles” folder in public directory and add some pdf files on that file so it will create zip file with those files.

Now you can test it by using following command:

php artisan serve

Now you can open bellow URL on your browser:

http://localhost:8000/download-zip

I hope it can help you…

#laravel #php #web-development

What is GEEK

Buddha Community

How to Create Zip File and Download in Laravel 6?

I am Developer

1597559012

Multiple File Upload in Laravel 7, 6

in this post, i will show you easy steps for multiple file upload in laravel 7, 6.

As well as how to validate file type, size before uploading to database in laravel.

Laravel 7/6 Multiple File Upload

You can easily upload multiple file with validation in laravel application using the following steps:

  1. Download Laravel Fresh New Setup
  2. Setup Database Credentials
  3. Generate Migration & Model For File
  4. Make Route For File uploading
  5. Create File Controller & Methods
  6. Create Multiple File Blade View
  7. Run Development Server

https://www.tutsmake.com/laravel-6-multiple-file-upload-with-validation-example/

#laravel multiple file upload validation #multiple file upload in laravel 7 #multiple file upload in laravel 6 #upload multiple files laravel 7 #upload multiple files in laravel 6 #upload multiple files php laravel

How To Create Zip File Using Ziparchive in Laravel

In this tutorial i will show you how to create zip file using zipArchive in laravel. Some times client’s have requirements to have functionalities like create zip file for documentation or images and download it.

So, at that time we can find many laravel packages to perform this task. But here, i am show you to how to create zip file in laravel using zipArchive without any package. Laravel provide ZipArchive class for create zip file in laravel,So i will use ZipArchive in laravel.

In below code i have created one function in laravel controller and added ZipArchive class.

How To Create Zip File Using Ziparchive in Laravel

https://websolutionstuff.com/post/how-to-create-zip-file-using-ziparchive-in-laravel

#laravel #php #how to create zip file using ziparchive in laravel #ziparchive #zip file #create zip in laravel

How To Create Zip File Using Ziparchive in Laravel

In this tutorial i will show you how to create zip file using zipArchive in laravel. Some times client’s have requirements to have functionalities like create zip file for documentation or images and download it.

So, at that time we can find many laravel packages to perform this task. But here, i am show you to how to create zip file in laravel using zipArchive without any package. Laravel provide ZipArchive class for create zip file in laravel,So i will use ZipArchive in laravel.

How To Create Zip File Using Ziparchive in Laravel

https://websolutionstuff.com/post/how-to-create-zip-file-using-ziparchive-in-laravel

#laravel #ziparchive #how to create zip file using ziparchive in laravel #ziparchive in laravel #make zip in laravel #ziparchive laravel example

How To Delete File From Public Folder In Laravel

In this post we will see how to remove/delete file from public storage, today I will give you demo how to remove file from storage folder in laravel.

So, here I will explain how to delete image from storage folder using Laravel File System and php function file_exists() and unlink().

How To Delete File From Public Folder In Laravel

https://websolutionstuff.com/post/how-to-delete-file-from-public-folder-in-laravel

#how to delete file from public folder in laravel #laravel #php #file #how to delete file from storage folder in laravel #laravel 6 remove file from public folder

I am Developer

1597647163

Laravel 7/6 Create Thumbnail from Image | Intervention Image Thumbnail

Laravel create thumbnail from image. Here, i will show you how to upload image and create thumbnail of uploaded image in laravel using intervention package.

Also using laravel intervention image thumbnai, you can resize the image size in laravel.

Laravel intervention image upload with Thumbnail and save to storage

  1. Install Laravel App
  2. Setup Database
  3. Install laravel intervention image thumbnail
  4. Generate migration file and model
  5. Make Route For Save and Display Image And Thumbnail
  6. Create Controller For Store Image & Thumbnail
  7. Create Blade View
  8. Make Folder
  9. Start Development Server

https://www.tutsmake.com/laravel-intervention-image-upload-using-ajax/

#laravel intervention image thumbnail #laravel create thumbnail from image #create thumbnail of image laravel 7/6 #laravel 7. x and 6. x - image upload with create thumbnail image