Commit cee9293f authored by hujun's avatar hujun

优化上传文件随机名生成

parent a9dd4729
......@@ -93,11 +93,11 @@ class UploadFileService
}
$date = date('Ymd');
$path .= $date;
$name_str = date('YmdHis') . mt_rand(10,1000);
$name_str = date('YmdHis');
if (is_array($_upload_file['tmp_name'])) {
foreach ($_upload_file['tmp_name'] as $k => $v) {
$name_str .= $k;
$name_str .= mt_rand(10,10000);
$_file = new File($v);
$file_info = pathinfo($_upload_file['name'][$k]);
$info = $_file->validate($valid_date)->move($path, $name_str . '.' . $file_info['extension']);
......@@ -115,7 +115,7 @@ class UploadFileService
}
} else {
$name_str .= mt_rand(10,1000);
$_file = new File($_upload_file['tmp_name']);
$file_info = pathinfo($_upload_file['name']);
$info = $_file->validate($valid_date)->move($path, $name_str . '.' . $file_info['extension']);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment