Files in a shared folder are accessible to everyone, unless your web server has a policy set to a specific directory.
If you currently cannot access the file in your shared folder, this is because it is possible that you are spelling the URL incorrectly, that is:
File in
/var/www/myapp/public/img/logo.png
Access will be through:
http:
Please note that the open part of your folder is not in your URL ONLY IF your web server is configured correctly and your file .htaccessis in place and can rewrite your URL.
For confidential files, you can save them in your application folder (or any other folder outside the public folder), which only your application will have access to, something like this might be okay:
/var/www/myapp/app/storage/<create a new folder here>
, :
Route::get('readfile/{fileName}', ['before' => 'auth', 'use' => 'ReadFileController@read']);
'before' => 'auth' , .
- , , :
class ReadFileController extends Controller {
public function read($fileName)
{
if(Auth::user()->id == 1)
{
return $this->getFile($fileName);
}
else
{
return Response::make(null, 403);
}
}
private function getFile($fileName)
{
...
}
}