Reputation: 1615
I'm trying to save a .txt
file in a folder named txts
inside my public folder but the method i'm using is not working:
$txt_nombre = 'nomina_'. $extras['desde'] .'_'. $extras['hasta'] .'.txt';
$txt_contenido = '';
foreach ($personal as $per) {
$txt_cadena = 'BNC ' . $per->cuenta_nomina . ' ' . $per->netos . ' ' . $per->cedula_identidad;
$txt_contenido .= $txt_cadena . "\n";
}
Storage::put('public/txts/'. $txt_nombre, $txt_contenido);
It doesn't even throw an error, my function keeps running but the file is not being saved. Any idea why?
Upvotes: 2
Views: 4611
Reputation: 8017
According to the Documentation
By default, the public disk uses the local driver and stores these files in storage/app/public.
Looking at your code, assuming that you haven't changed default configuration, your file should be created in storage/app/public/public/txts/
folder.
I am not sure how Laravel's Storage abstraction handles non-existing folders so you might want, for test, try using just Storage::put('file.txt', "content")
and see if it's being created in storage/app/public
folder
Upvotes: 3