Thumbnails cannot be saved to subdirectories after uploading files in THINKPHP3.0. This is because the getSubName() function in the upload class UploadFile.class.php can only create a subdirectory of the original image but not a subdirectory of the thumbnail. , it can be said to be a BUG.
Solution 1 (the official solution provided by ThinkPHP, I have not tested it): Upgrade to the latest UploadFile.class.php of ThinkPHP3.1 (https://github.com/liu21st/extend/tree/master/Extend /Library/ORG/Net), replace the original UploadFile.class.php
after downloading
Solution 2: Modify some codes of UploadFile.class.php
This is my own solution, add a thumbnail subdirectory generation function
Step 1>>
Imitate the getSubName() function in UploadFile.class.php to create a getThumbSubName() function
The code is as follows
|
Copy code
|
||||
private function getThumbSubName($file) { switch($this->subType) {
|
$dir = date($this->dateFormat,time());
$name = md5($this->thumbPath);
Step 2>>The code is as follows | Copy code |
$thumbPath = $this->thumbPath?$this->thumbPath.($this->autoSub?$this->getThumbSubName($file).'/':''):$file[ 'savepath']; http://www.bkjia.com/PHPjc/632175.htmlwww.bkjia.comtruehttp: //www.bkjia.com/PHPjc/632175.htmlTechArticleTHINKPHP3.0 After uploading the file, the thumbnail cannot be saved to the subdirectory because of the UploadFile.class.php upload The getSubName() function in the class can only create a subdirectory of the original image but cannot create a thumbnail image... |