上传具有不同名称的图像但保留文件扩展名

When i save image with my form i change the file name. Everything works nice except file extension. When i change file name the extension is missing and file is saved without it. Please help me to solve my problem i want to store also image extension.

This is my code where i update image name.

$image = $request->file('image');

if ($image) {

    $imgPath = 'public/post-image/';
    $imgName = uniqid('img_');
    $store = $request->file('image')->storeAs(
        $imgPath, $imgName
    );

    $post->image = $imgName;

}

Try this:

$image = $request->file('image');

if ($image) {

    $imgPath = 'public/post-image/';
    $imgName = uniqid('img_') . '.' . $image->extension();
    $store = $image->storeAs($imgPath, $imgName);
    $post->image = $imgName;
}