“Blueimp jQuery File Upload” rename files

后端 未结 7 1924
挽巷
挽巷 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:57

    For those who only what to give the name through the $options:

    Replace (line 1056?)

    $file->name = $this->get_file_name($uploaded_file, $name, $size, $type, $error, $index, $content_range);
    

    with

    $extension = pathinfo($name , PATHINFO_EXTENSION);
    if ( $extension != "" ){
        $extension = "." . $extension;
    }
    
    $file->name = (isset($this->options['filename']) && isset($extension) ) 
         ? $this->options['filename'] . $extension
         : $this->get_file_name($uploaded_file, $name, $size, $type, $error, $index, $content_range);
    

    Then give the name in the option like this:

    $upload_handler = new UploadHandler(array(['filename' => 'whatever' ]));
    
    0 讨论(0)
提交回复
热议问题