xxxxxxxxxx
<script src="{{ asset('js/loader.js'); }}"></script>
xxxxxxxxxx
use Illuminate\Http\Request;
public function uploadFile(Request $request)
{
if ($request->hasFile('file')) { // Check if a file was uploaded
$file = $request->file('file'); // Get the uploaded file
if ($file->isValid()) { // Check if the file is valid
$filename = $file->getClientOriginalName(); // Get the original filename
$file->storeAs('public', $filename); // Store the file in the "public" folder
return "File uploaded successfully!";
}
}
return "No file was uploaded.";
}
xxxxxxxxxx
You can create a new storage disc in config/filesystems.php
'public_uploads' => [
'driver' => 'local',
'root' => public_path() . '/uploads',
],
And store files like this:
if(!Storage::disk('public_uploads')->put($path, $file_content)) {
return false;
}