How to read file content in Public folder with Laravel

If you want to read the content of a file in the public folder using Laravel, you can use this code

$file_name = "test.dat";
$file_url = 'public\subfolder\\'. $file_name;
$content = file_get_contents(base_path($map_url));

base_path is a helper function to generate a fully qualified path to a given file relative to the project root directory