Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

set file name laravel

I upload file with this code:

$this->form->file_path = $this->file->store('files/'.$this->file_name.'.pdf', 'public');

but cannot set the file name correctly. It stores file under file_name.pdf with a random name.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

When you use the store() method, the file name will generated for you. If you want to set the name yourself, you should use the storeAs method:

$this->file->storeAs('files', $this->file_name.'.pdf', 'public');
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading