Very good people,
Today I have the following doubt; I have a server that as soon as I log in as a regular user, I redirect it to a specific route ("/front/resources/Timmy/hello.txt"). I would like this to be able to see certain files on my server through a url ( url: "server.es/front/resources/$cliente/$nombre_archivo" -> file from inside the server: "/ web / reporting /client_data/Clients_Reports/$cliente/hola.txt ").
I show you what I have done so far:
-
This is the controller that receives the data from the url to choose the client and the name of the file (the path of the controller corresponds to that of the clients):
public function resources($client, $name){
$client1 = str_replace('..', '', $client); $name1 = str_replace('..', '', $name); $urlComplete = __DIR__ . '../../client_data/Clients_Reports/'.$client1.'/'.$name1;
//Muestra el contenido del archivo:
echo $client." -- ".$name.": "; echo "<br>"; $output = file_get_contents($urlComplete); echo $output; }
-
Here are the routes of interest ( web.php ):
Route::get('/front/resources/{client}/{name}','FrontController@resources');
-
And this the error you give me:
file_get_contents(/usr/home/servidor.es/web/reporting/app/Http/Controllers../../client_data/Clients_Reports/Timmy/holi.txt): failed to open stream: No such file or directory
I think the route that I found is wrong (since it worked for me locally) and therefore I am looking for the correct path so that the client can access the text file in question.
Thanks in advance.