Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

Gabonator's avatar

Rename image name in src path

I saving files using the save () method and the image has the name like qwewerwasdfasdfasdfasdf.jpg

For SEO reasons, want to make in blade path more human and was rename picture like user-> firstName. user-> lastName.jpg

How to do it?

Thx

0 likes
3 replies
Snapey's avatar

Docs;

Specifying A File Name

If you would not like a file name to be automatically assigned to your stored file, you may use the storeAs method, which receives the path, the file name, and the (optional) disk as its arguments:

$path = $request->file('avatar')->storeAs(
    'avatars', $request->user()->id
);
Gabonator's avatar

Hmmm, yes but I need rewrite saved file qwewerwasdfasdfasdfasdf.jpg in blade to

scr="userName".

kenny11's avatar

what you should do is name a file when saving it

Please or to participate in this conversation.