“Blueimp jQuery File Upload” rename files

后端 未结 7 2031
挽巷
挽巷 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:43

    Thanks for that !

    But I got a problem, I would like to rename with a field title, I've try to use that :

    protected function handle_form_data($file, $index) {
        $file->title = @$_REQUEST['title'][$index];
    }
    protected function generate_unique_filename($filename = "") {
        $extension = "";
        if ( $filename != "" )
        {
            $extension = pathinfo( $filename, PATHINFO_EXTENSION );
            if ( $extension != "" ) {
                $extension = "." . $extension;
            }
        }
        return $file->title . $extension;
    }
    

    But I got a JSON error everytime... (The @$_REQUEST['title'][$index]; work well, I use it for save it in my database)

提交回复
热议问题