Solution 1 (I have not tested ThinkPHP's official solution): upgrade ThinkPHP3.1 to the latest UploadFile. class. php (https://github.com/liu21st/extend/tree/master/Extend/Library/ORG/Net), download and replace the original UploadFile. class. php
Solution 2: modify part of UploadFile. class. php code
This is a solution by myself. Add a sub-directory of the thumbnail to generate a function.
Step 1>
UploadFile. class. php imitates the getSubName () function to create a getThumbSubName () function.
The code is as follows: |
Copy code |
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, change row 158
The code is as follows: |
Copy code |
$ ThumbPath = $ this-> thumbPath? $ This-> thumbPath. ($ this-> autoSub? $ This-> getThumbSubName ($ file). '/': ''): $ file ['savepath']; |