Skip to content

Instantly share code, notes, and snippets.

@Tynael
Last active January 26, 2023 16:59
Show Gist options
  • Save Tynael/0249b31ba90fcb4cbdef8d2ae238904c to your computer and use it in GitHub Desktop.
Save Tynael/0249b31ba90fcb4cbdef8d2ae238904c to your computer and use it in GitHub Desktop.
How to Check If File Exists Using Laravel
<?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
}
}
@Tynael
Copy link
Author

Tynael commented Jan 26, 2023

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment