“Blueimp jQuery File Upload” rename files

后端 未结 7 2051
挽巷
挽巷 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条回答
  •  闹比i
    闹比i (楼主)
    2021-02-19 15:52

    For multiple files download, I add some lines from SananTheBest as following. Actually, The reason files can not upload because the files name are same even using date as mentioned in his pervious post. (Thanks you)

    protected function generate_unique_filename($filename = "")
    {
    
        $extension = "";
        if ( $filename != "" )
        {
            $extension = pathinfo($filename , PATHINFO_EXTENSION);
    
            if ( $extension != "" )
            {
                $extension = "." . $extension;
            }
        }
        //$filenamegen = date('ymdHis').generateRandomString();
        $characters = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
        $charactersLength = strlen($characters);
        $randomString = "";
        for ($i = 0; $i < 5 ; $i++) {
            $randomString .= $characters[rand(0, $charactersLength - 1)];
        }
    
    
        //$filenamerandom=$filename.".jpg";
        //return md5(date('Y-m-d H:i:s:u')). $extension;
    
        return date('ymdHis').$randomString . $extension ;
    }
    

提交回复
热议问题