“Blueimp jQuery File Upload” rename files

后端 未结 7 2026
挽巷
挽巷 2021-02-19 15:22

I\'m using the Blueimp jQuery file upload tool. I\'d like to completely rename the files as they\'re uploaded. Since photos are being added to a unique directory based on the us

7条回答
  •  难免孤独
    2021-02-19 15:51

    Why not trying uniqid() to generate an unique name?

    protected function generate_unique_filename( $filename = "" )
    {
        $extension = "";
        if ( $filename != "" )
        {
            $extension = pathinfo( $filename, PATHINFO_EXTENSION );
    
            if ( $extension != "" )
            {
                $extension = "." . $extension;
            }
        }
        return md5( uniqid() ) . $extension;
        //or simply return uniqid() . $extension;
    }       
    

提交回复
热议问题