How to upload files in Laravel directly into public folder?

To upload files directly into the public folder in Laravel, you can use the storeAs method provided by the Storage facade.

You can use the following code snippet to upload a file:

$path = $request->file('file')->storeAs('public', 'your_file_name.ext');

This will store the uploaded file in the public folder with the name your_file_name.ext.

You can then access the file using the URL /storage/your_file_name.ext.

Alternatively, you can move the file to the public folder after uploading it to the default storage location using the move method.

<?php

$path = $request->file('file')->store('temp');
$file = $request->file('file');
$fileName = $file->getClientOriginalName();
$file->move(public_path('uploads'), $fileName);

This will store the file into the public/uploads directory.