Plugin Directory

Changeset 2600933


Ignore:
Timestamp:
09/18/2021 03:26:48 AM (5 years ago)
Author:
chahuang
Message:

fix cos bug

File:
1 edited

Legend:

Unmodified
Added
Removed
  • tencentcloud-cos/tags/V1.0.2/class-tencent-cloud-cos.php

    r2596141 r2600933  
    274274        if (isset($tcwpcos_options['opt']['auto_rename_config'])
    275275            && $tcwpcos_options['opt']['auto_rename_config']['auto_rename_switch'] === 'on') {
     276            $extension = pathinfo($filename, PATHINFO_EXTENSION);
     277            $tmp_filename = pathinfo($filename, PATHINFO_FILENAME);
     278            $time = date('YmdHis', current_time('timestamp'));
     279            $rand = mt_rand(100, 999);
    276280            if ($tcwpcos_options['opt']['auto_rename_config']['auto_rename_style_choice'] === '0') {
    277281                // 默认(日期+随机串)
    278                 return date("YmdHis") . mt_rand(100, 999)
    279                     . pathinfo($filename, PATHINFO_EXTENSION);
     282                return "{$time}{$rand}.{$extension}";
    280283            } elseif ($tcwpcos_options['opt']['auto_rename_config']['auto_rename_style_choice'] === '1') {
    281284                // 格式一(日期+文件名+随机串)
    282                 return date("YmdHis") . pathinfo($filename)['filename'] . mt_rand(100, 999) . "."
    283                     . pathinfo($filename, PATHINFO_EXTENSION);
     285                return "{$time}{$tmp_filename}{$rand}.{$extension}";
    284286            } elseif ($tcwpcos_options['opt']['auto_rename_config']['auto_rename_style_choice'] === '2') {
    285287                //  格式二(自定义前缀+日期+文件名称+自定义后缀)
    286                 return $tcwpcos_options['opt']['auto_rename_config']['auto_rename_customize_prefix'] .
    287                     date("YmdHis") . pathinfo($filename)['filename'] . $tcwpcos_options['opt']['auto_rename_config']['auto_rename_customize_postfix']
    288                     . "." . pathinfo($filename, PATHINFO_EXTENSION);
    289             }
    290         } else {
    291             return $filename;
    292         }
     288                return "{$tcwpcos_options['opt']['auto_rename_config']['auto_rename_customize_prefix']}"
     289                    . "{$time}{$tmp_filename}"
     290                    . "{$tcwpcos_options['opt']['auto_rename_config']['auto_rename_customize_postfix']}.{$extension}";
     291            }
     292        }
     293
     294        return $filename;
     295    }
     296
     297    /**
     298
     299    }
     300    } else {
     301    return $filename;
     302    }
    293303    }
    294304
Note: See TracChangeset for help on using the changeset viewer.