Skip to main content

How to upload file in public folder by storage function in Laravel 8?

upload file in public folder by storage function in Laravel 8



//filesystems.php   


   'disks' => [

        'uploads' => [

             'driver' => 'local',

             'root' => public_path() .'/upload',

             'visibility' => 'public',

        ]

    ]

//My-project(Laravel)\public\upload\images\blogs


use Validator;

use file;

use Illuminate\Support\Facades\Storage;



$request->validate([

'featured_image' => 'required|max:2048',

]);


$name = $request->file('featured_image')->getClientOriginalName();

$file_path = $request->file('featured_image')->storeAs('images/blogs', $name, 'uploads');

Comments

Popular posts from this blog

How to check date format in PHP?

Check date format in PHP function isCorrectDateFromat($date){     if(!empty($date)){         $dateString = $date; // Replace this with your date string         $format = "Y-m-d"; // Replace this with your expected date format         $dateTime = DateTime::createFromFormat($format, $dateString);         if ($dateTime === false) { /*             echo "The date is not in the correct format."; */         } else {             $errors = DateTime::getLastErrors();             if (empty($errors)) { /*                 echo "The date is in the correct format."; */                 return true;             } else { /*                 echo "...