Laravel – check if folder exists before create directory

Today, We want to share with you Laravel – check if folder exists before create directory.In this post we will show you Laravel Check if a directory exists based on path, hear for How to delete files if exists from public folder in Laravel 5.8 we will give you demo and example for implement.In this post, we will learn about PHP Laravel 5.8 Create directory if it doesn’t exist with an example.

Laravel – check if folder exists before create directory

There are the Following The simple About Laravel – check if folder exists before create directory Full Information With Example and source code.

As I will cover this Post with live Working example to develop unable to create the directory laravel, so the how to create a folder using laravel for this example is following below.

Laravel – Create Directory if not Exists

public function formTestSubmit(Request $request)
{
    $get_path = public_path('upload/YOUR_WEBSITE.com');
   
    if(!File::isDirectory($get_path)){
        File::makeDirectory($get_path, 0777, true, true);
    }
   
    dd('check if folder exists before create directory :  ---> done');
}

Laravel – Check if File Exists

if(file_exists(public_path('images/product_test001.jpg'))){
    dd('your File is exists.');
}else{
    dd('your File is not exists.');
}

Laravel – Check if File Readable

 

Laravel – Check if Link File

Laravel – link to a file saved in storage folder

use Illuminate\Support\Facades\Storage;

$url = Storage::url('file1.jpg');
Web Programming Tutorials Example with Demo

Read :

Summary

You can also read about AngularJS, ASP.NET, VueJs, PHP.

I hope you get an idea about Laravel – check if folder exists before create directory.
I would like to have feedback on my infinityknow.com blog.
Your valuable feedback, question, or comments about this article are always welcome.
If you enjoyed and liked this post, don’t forget to share.

Leave a Comment