ThinkPHP3.0 thumbnail cannot be saved to a subdirectory
- 2020-05-26 07:53:37
- OfStack
Solution 1 (ThinkPHP official offer, I have not tested) : upgrade to ThinkPHP3. 1 latest UploadFile. class. php (https: / / github com/liu21st/extend/tree/master/Extend/Library/ORG/Net), replace the original UploadFile. After downloading class. php
Solution 2: modify part of the code for UploadFile.class.php
This is to do their own solution, add a slightly thumbnail subdirectory generation function
Step 1
>
>
UploadFile.class.php creates an getThumbSubName() function that mimics the getSubName() function
private function getThumbSubName($file) {
switch($this->subType) {
case 'date':
$dir = date($this->dateFormat,time());
break;
case 'hash':
default:
$name = md5($this->thumbPath);
$dir = '';
for($i=0;$i<$this->hashLevel;$i++) {
$dir .= $name{$i}.'/';
}
break;
}
if(!is_dir(($this->thumbPath).$dir)) {
mkdir(($this->thumbPath).$dir);
}
return $dir;
}
Step 2 > >
In UploadFile.class.php, line 158 is changed
$thumbPath = $this->thumbPath?$this->thumbPath.($this->autoSub?$this->getThumbSubName($file).'/':''):$file['savepath'];
Finally problem solved!