wertyu
wertyu

Reputation: 121

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.

Upvotes: 0

Views: 212

Answers (1)

Rwd
Rwd

Reputation: 35170

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');

Upvotes: 1

Related Questions