xxxxxxxxxx
$filePath = public_path("name_of_your_file.txt");
return Response::download($filePath);
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;
}
xxxxxxxxxx
// In config/filesystems.php, you could do this...
// change the root element in public
'disks' => [
'public' => [
'driver' => 'local',
'root' => public_path() . '/uploads',
'url' => env('APP_URL').'/public',
'visibility' => 'public',
]
]
dd($image->store('images', 'public'));