Last active
January 26, 2023 16:59
-
-
Save Tynael/0249b31ba90fcb4cbdef8d2ae238904c to your computer and use it in GitHub Desktop.
How to Check If File Exists Using Laravel
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
declare(strict_types=1); | |
namespace App\Http\Controllers; | |
use App\Http\Controllers\Controller; | |
use Illuminate\Support\Facades\File; | |
class HomeController extends Controller | |
{ | |
public function index() | |
{ | |
$file1 = File::exists(storage_path('app/public/myFile.json')); // returns true/false | |
$file2 = File::isFile(storage_path('app/public/myFile.json')); // returns true/false | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Example used in https://neutrondev.com/check-if-file-exists-laravel/