PHP: Get file extension not working on uploads to S3

后端 未结 12 658
我寻月下人不归
我寻月下人不归 2020-12-06 17:49

I am using the Amazon S3 API to upload files and I am changing the name of the file each time I upload.

So for example:

Dog.png > 3Sf5f.png

Now I got

12条回答
  •  心在旅途
    2020-12-06 18:45

    I think something as simple as below should work to extract file extension from the file-name:

    function getFileExtension($fileName)
    {
        $ext = '';
        if(strpos($fileName, ".") !== false)
        {
            $ext = end(explode(".", $fileName));
        }
        return $ext;
    }
    

提交回复
热议问题