Search code examples
laravelstore

why store() in laravel change the file name in storage?


I have this code in laravel to store an image but why does the image name change when I checked it on the folder ?! Please help me I'm really frustrated !

public function postStore(Request $req){//Bikin toko baru


        $req->image->store('images','public');
        

        $req->validate([
            'name'=>['string','min:5'],
            'address'=>['string','min:10'],
            'description'=>['string','min:20']
            // 'image'=>'mimes:jpg,png,jpeg'

        ]);

Solution

  • please try this

    $path = $request->file('image')->storeAs(
            'images', $request->file('image')->getClientOriginalName()
        );