I am saving a pdf file as follows:
if ($request->hasFile('tCertificado')) {
foreach ($request -> tCertificado as $certificado) {
$path_certificado = $certificado -> store('local');
}
}
So the files are saved in the storage/app/local folder . But what I want is to save said certificate in the following way:
My file: mycertificate.pdf
Saving in storage/app/local as follows:
storage/app/local/ USER_NAME /mycertificate _280420200130 .pdf
Where USER_NAME is the value of an input text that is sent along with the images.
You can use the storeAs() function to generate the name and store in the folder you want.
To add a new folder, simply add to the path.
local/otracarpeta/otrasubcarpeta
(For the example I will use static variables that you would have to replace with your inputs)
You can use the Storage facade
Your method would look like this.
What the storage facade does is precisely make it easy to save and retrieve files from storage or disks.
You just have to verify that it has the appropriate permissions for the tasks you want to do and that it is properly configured.
The same is in the laravel documentation.