Table of Contents
thinkphp3.2.2 realizes the method of generating multiple thumbnails, thinkphp3.2.2 has multiple thumbnails
Home Backend Development PHP Tutorial thinkphp3.2.2 realizes the method of generating multiple thumbnails, thinkphp3.2.2 multiple_PHP tutorial

thinkphp3.2.2 realizes the method of generating multiple thumbnails, thinkphp3.2.2 multiple_PHP tutorial

Jul 13, 2016 am 10:11 AM
thinkphp method

thinkphp3.2.2 realizes the method of generating multiple thumbnails, thinkphp3.2.2 has multiple thumbnails

The example in this article describes the method of generating multiple thumbnails in thinkphp3.2.2. Share it with everyone for your reference.

The specific implementation method is as follows:

Copy code The code is as follows:
public function dz_upload() { //Upload multiple thumbnails Upload 2 thumbnails
If (isset($_FILES['ori_img'])){
$upload = new ThinkUploadFile(); // Instantiate upload class
$upload->maxSize = 3000000;//Set the attachment upload size C('UPLOAD_SIZE');
//$upload->savePath = './Public/Uploads/' . $path; //Set the attachment upload directory
$upload->savePath = './Public/Uploads/' . 'thumb/'; // Set the attachment upload directory
$upload->allowExts = array('jpg', 'gif', 'png', 'jpeg'); // Set attachment upload type
$upload->saveRule = 'time';
$upload->uploadReplace = true; //Whether the file with the same name exists or whether to overwrite
$upload->thumb = true; //Whether to thumbnail the uploaded file
$upload->thumbMaxWidth = '100,300'; //Thumbnail processing width
$upload->thumbMaxHeight = '50,150'; //Thumbnail processing height
//$upload->thumbPrefix = $prefix; //Thumbnail prefix
$upload->thumbPrefix = 'm_,s_'; //Produce 2 thumbnails
//$upload->thumbPath = './Public/Uploads/' . $path . date('Ymd', time()) . '/'; //Thumbnail saving path
$upload->thumbPath = './Public/Uploads/' . 'thumb/' . date('Ymd', time()) . '/'; // Thumbnail saving path
 
//$upload->thumbRemoveOrigin = true; //Delete the original image after uploading it
$upload->thumbRemoveOrigin = false; //Delete the original image after uploading it
$upload->autoSub = true; //Whether to use subdirectories to save images
$upload->subType = 'date'; //Subdirectory saving rules
$upload->dateFormat = 'Ymd'; //The time format when the subdirectory saving rule is date

if (!$upload->upload()) {//Upload error message
echo json_encode(array('msg' => $this->error($upload->getErrorMsg()), 'status' => 0));
} else {// Upload successful Get uploaded file information
$info = $upload->getUploadFileInfo();
$picname = $info[0]['savename'];

         $picname = explode('/', $picname);                                     //$picname = $picname[0] . '/' . $prefix . $picname[1];
$picname = $picname[0] . '/' . '_hz' . $picname[1];
                    print_r($picname);                        echo json_encode(array('status' => 1, 'msg' => $picname));
}  
}
}

Calling method:



Copy code The code is as follows:$k=A("Index"); // Call the koo method of the controller Index Key points (lish)
$slt=$k->dz_upload();

It should be noted here that thinkphp3.2.2 does not have the UploadFile and UploadImage classes. You need to extract them from the extension package and add them yourself, and put them in the ThinkPHPLibraryThink directory.

I hope this article will be helpful to everyone’s PHP programming based on the ThinkPHP framework.

http://www.bkjia.com/PHPjc/930189.html

truehttp: //www.bkjia.com/PHPjc/930189.htmlTechArticlethinkphp3.2.2 realizes the method of generating multiple thumbnails, thinkphp3.2.2 multiple thumbnails This article describes thinkphp3.2.2 Implement a method to generate multiple thumbnails. Share it with everyone for your reference. Tool...
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot Article Tags

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

How to write a novel in the Tomato Free Novel app. Share the tutorial on how to write a novel in Tomato Novel. How to write a novel in the Tomato Free Novel app. Share the tutorial on how to write a novel in Tomato Novel. Mar 28, 2024 pm 12:50 PM

How to write a novel in the Tomato Free Novel app. Share the tutorial on how to write a novel in Tomato Novel.

How to enter bios on Colorful motherboard? Teach you two methods How to enter bios on Colorful motherboard? Teach you two methods Mar 13, 2024 pm 06:01 PM

How to enter bios on Colorful motherboard? Teach you two methods

How to recover deleted contacts on WeChat (simple tutorial tells you how to recover deleted contacts) How to recover deleted contacts on WeChat (simple tutorial tells you how to recover deleted contacts) May 01, 2024 pm 12:01 PM

How to recover deleted contacts on WeChat (simple tutorial tells you how to recover deleted contacts)

Summary of methods to obtain administrator rights in Win11 Summary of methods to obtain administrator rights in Win11 Mar 09, 2024 am 08:45 AM

Summary of methods to obtain administrator rights in Win11

Quickly master: How to open two WeChat accounts on Huawei mobile phones revealed! Quickly master: How to open two WeChat accounts on Huawei mobile phones revealed! Mar 23, 2024 am 10:42 AM

Quickly master: How to open two WeChat accounts on Huawei mobile phones revealed!

How to run thinkphp project How to run thinkphp project Apr 09, 2024 pm 05:33 PM

How to run thinkphp project

Detailed explanation of Oracle version query method Detailed explanation of Oracle version query method Mar 07, 2024 pm 09:21 PM

Detailed explanation of Oracle version query method

The secret of hatching mobile dragon eggs is revealed (step by step to teach you how to successfully hatch mobile dragon eggs) The secret of hatching mobile dragon eggs is revealed (step by step to teach you how to successfully hatch mobile dragon eggs) May 04, 2024 pm 06:01 PM

The secret of hatching mobile dragon eggs is revealed (step by step to teach you how to successfully hatch mobile dragon eggs)

See all articles