简体   繁体   中英

Laravel - custom name while uploading image using storage

I am trying to upload a file using laravel Storage ie

$request->file('input_field_name')->store('directory_name');

but it is saving the file in specified directory with random string name.

Now I want to save the uploaded file with custom name ie

current/badge-group-${badge_group_id}/badge-${badge_id}/${imageName}

with actual file name. What is the fastest and simplest way to achieve this functionality?

https://laravel.com/docs/5.4/requests#storing-uploaded-files

You can act on the file in the request object directly and then call storeAs() to specify a filename

$request->file('input_field_name')->storeAs('directory_name'); 

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM