1

I'm trying to save an image that is coming from my request in my storage, but something strange is happening: I have the following code

$ request-> file ('UploadIMG') -> store ('public'. '/'. 'clients');

when it is executed it saves the image in the following location

storage \ app \ public \ clients \ dUpBTL0V25h2Q1825IUmvvIZhcwVPixLaVDdItuG.jpg

I wanted to change this value and set a name, so I used the following code

Storage :: disk ('local') -> put ('clients'.'/'.$ fileName, $Image, 'public');

let's say my $ fileName has the value of 01.jpg when I run that storage it creates

storage \ app \ clients \ 01.jpg \ dUpBTL0V25h2Q1825IUmvvIZhcwVPixLaVDdItuG.jpg

it ends up creating a folder with the name of the image and places the image with the random name, how do I get a name for my image?

2 Answers 2

2

You can use the storeAs() method to save uploded file and name it:

$request->file('UploadIMG')->storeAs('public/clients', $fileName);
Sign up to request clarification or add additional context in comments.

Comments

1
    $file = $request->file('pic');
    $picName = $file->getClientOriginalName();
    $imagePath = '/public/clients';
    $file->move(public_path($imagePath), $picName);

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.