How to check File exist in Folder or Not in Laravel 6 ?

How to check File exist in Folder or Not in Laravel 6 ?

laravel 6 check if file exists, laravel 6 check file exists, file is exists or not in laravel 6, check file exists in laravel 6, how to check file exists or not laravel 6,example of check file exist in laravel 6,laravel 6 file exists or not

Laravel 6 Tutorial - How to make Auth in Laravel 6

Laravel 6 Tutorial - How to make Auth in Laravel 6

Are you looking for make Auth in Laravel 6 then I will help you to make Authentication using Laravel UI package in Laravel 6. I will explain to you how to create login and registration using Auth in Laravel 6.

Originally published at https://itsolutionstuff.com

Laravel 6 provide septate composer package for creating Auth scaffold in Laravel 6 application. Whenever you require to create auth in Laravel 6 then you must have to install Laravel/ui package in Laravel 6.

Using Laravel/ui you can create simple view with Auth as same you did before you do. But you have to use Vue.js or React.js with Auth view in Laravel 6. But they does not provide as default you have to follow few step to do Auth.

You have to follow few step to make auth in your Laravel 6 application.

First you need to install laravel/ui package as like bellow:

composer require laravel/ui

After that you can run following command and check ui commands info.

php artisan ui --help

Output:

Description:
  Swap the front-end scaffolding for the application
Usage:
  ui [options] [--] 
Arguments:
  type                   The preset type (bootstrap, vue, react)
Options:
      --auth             Install authentication UI scaffolding
      --option[=OPTION]  Pass an option to the preset command (multiple values allowed)
  -h, --help             Display this help message
  -q, --quiet            Do not output any message
  -V, --version          Display this application version
      --ansi             Force ANSI output
      --no-ansi          Disable ANSI output
  -n, --no-interaction   Do not ask any interactive question
      --env[=ENV]        The environment the command should run under
  -v|vv|vvv, --verbose   Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug

You can use following commands for creating auth:

Using Vue:

php artisan ui vue --auth

Using React:

php artisan ui react --auth

Now you need to run npm command, otherwise you can not see better layout of login and register page.

Install NPM:

npm install

Run NPM:

npm run dev

Now you can run and check your app.

It will work great.

I hope it can help you....

Thanks for reading

If you liked this post, share it with all of your programming buddies!

Follow me on Facebook | Twitter

Further reading

Laravel 5.8 Tutorial for Beginners

What’s New in Laravel 6.0

Laravel 6 CRUD Application Tutorial

Laravel 6 Image Upload Tutorial


How to Create Zip File and Download in Laravel 6?

How to Create Zip File and Download in Laravel 6?

In this tutorial, i am writing example of Laravel 6 create zip archive file and download in response. I will give you example step by step how to create zip file from folder and download in Laravel 6. We will create zip file using ziparchive class in PHP Laravel 6 Application.

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', '[email protected]');
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...

How to create file uploading with Laravel 6 Application?

How to create file uploading with Laravel 6 Application?

In this tutorial, I will help you to create file uploading with Laravel 6 Application. We will create simple file upload like pdf, image, xlx, zip etc in Laravel 6

You can see file upload in laravel 6 using request facade. we will file upload with validation like mimes, max file upload etc, So it can protect to upload script.

In this example, we will create two routes one for get method and another for post method. we created simple form with file input. So you have to simple select file and then it will upload in "uploads" directory of public folder. So you have to simple follow bellow step and get file upload in laravel 6 application.

Step 1 : Install Laravel 6

First of all, we need to get fresh laravel 6 version application using bellow command because we are going from scratch, So open your terminal OR command prompt and run bellow command:

composer create-project --prefer-dist laravel/laravel blog

Step 2: Create Routes

In next step, we will add new two routes in web.php file. One route for generate form and another for post method So let's simply create both route as bellow listed:

routes/web.php

Route::get('file-upload', '[email protected]')->name('file.upload');

Route::post('file-upload', '[email protected]')->name('file.upload.post');

Laravel 6 CRUD Application Tutorial

Step 3: Create FileUploadController

In third step we will have to create new FileUploadController and here we have to write two method fileUpload() and fileUploadPost(). So one method will handle get method another one for post. So let's add code.

app/Http/Controllers/FileUploadController.php

<?php

   

namespace App\Http\Controllers;

  

use Illuminate\Http\Request;

  

class FileUploadController extends Controller

{

    /**

     * Display a listing of the resource.

     *

     * @return \Illuminate\Http\Response

     */

    public function fileUpload()

    {

        return view('fileUpload');

    }

  

    /**

     * Display a listing of the resource.

     *

     * @return \Illuminate\Http\Response

     */

    public function fileUploadPost(Request $request)

    {

        $request->validate([

            'file' => 'required|mimes:pdf,xlx,csv|max:2048',

        ]);

  

        $fileName = time().'.'.$request->file->extension();  

   

        $request->file->move(public_path('uploads'), $fileName);

   

        return back()

            ->with('success','You have successfully upload file.')

            ->with('file',$fileName);

   

    }

}

Step 3: Create Blade File

At last step we need to create fileUpload.blade.php file and in this file we will create form with file input button. So copy bellow and put on that file.

resources/views/fileUpload.blade.php

How to use Yajra Datatables in Laravel 6?

<!DOCTYPE html>

<html>

<head>

    <title>laravel 6 file upload example - ItSolutionStuff.com.com</title>

    <link rel="stylesheet" href="http://getbootstrap.com/dist/css/bootstrap.css">

</head>

  

<body>

<div class="container">

   

    <div class="panel panel-primary">

      <div class="panel-heading"><h2>laravel 6 file upload example - ItSolutionStuff.com.com</h2></div>

      <div class="panel-body">

   

        @if ($message = Session::get('success'))

        <div class="alert alert-success alert-block">

            <button type="button" class="close" data-dismiss="alert">×</button>

                <strong>{{ $message }}</strong>

        </div>

        <img src="uploads/{{ Session::get('file') }}">

        @endif

  

        @if (count($errors) > 0)

            <div class="alert alert-danger">

                <strong>Whoops!</strong> There were some problems with your input.

                <ul>

                    @foreach ($errors->all() as $error)

                        <li>{{ $error }}</li>

                    @endforeach

                </ul>

            </div>

        @endif

  

        <form action="{{ route('file.upload.post') }}" method="POST" enctype="multipart/form-data">

            @csrf

            <div class="row">

  

                <div class="col-md-6">

                    <input type="file" name="file" class="form-control">

                </div>

   

                <div class="col-md-6">

                    <button type="submit" class="btn btn-success">Upload</button>

                </div>

   

            </div>

        </form>

  

      </div>

    </div>

</div>

</body>

  

</html>

Step 4: Create "uploads" Directory

in last step, we need to create new directory "uploads" with full permission, So let's create new folder on public folder.

After that you can check it.

I hope it can help you...