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.

Read Also:  Ajax Shopping Cart PHP MYSQLi Tutorial With Example

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

<?php  
$myfile = public_path('employee/invoice.txt'); 
  
// checking whether file is readable or not 
if (is_readable($myfile))  
{ 
    echo '$myfile is readable'; 
}  
else 
{ 
    echo '$myfile is not readable'; 
} 
?> 

Laravel – Check if Link File

Laravel – link to a file saved in storage folder

Read Also:  jQuery Dynamically addClass and removeClass

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.

Read Also:  Laravel Get Absolute Path Document Root Base URL

Related FAQ

Here are some more FAQ related to this Article:

  1. Read Also:  Multiple Database Connections using Laravel
  2. Read Also:  How to get last executed query in PHP Codeigniter?
  3. Read Also:  Group By with Date using Laravel Collection
  4. Read Also:  Angular Multiple Carousel Image Slider
  5. Read Also:  Simple Laravel Query Dumper Getquerylog
  6. Read Also:  Bind DropdownList with Ng-Repeat using Angular Example
  7. Read Also:  How to create a logfile in PHP
  8. Read Also:  how to add multiple input fields dynamically in javascript and PHP?
  9. Read Also:  jQuery Dynamically addClass and removeClass
  10. Read Also:  Multiple Database Connections using Laravel
CLOSEX