ThinkPHP3.0 thumbnails cannot be saved to a subdirectory of the workaround _php instance

Source: Internet
Author: User
Solution One (thinkphp officially provided, I have not tested): upgrade to ThinkPHP3.1 the latest UploadFile.class.php (https://github.com/liu21st/ extend/tree/master/extend/library/org/net), replace the original UploadFile.class.php after downloading

workaround Two: Modify part of the code for UploadFile.class.php

This is your own solution, add a thumbnail of the sub-directory generation function
Step 1>>

Create a Getthumbsubname () function in UploadFile.class.php by imitating the getsubname () function

Copy the Code code as follows:
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>>

UploadFile.class.php in line 158 instead
Copy the Code code as follows:
$thumbPath = $this->thumbpath? $this->thumbpath. ($this->autosub? $this->getthumbsubname ($file). ' /': '): $file [' Savepath '];

Finally solve the problem!

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.