


thinkphp3.2.2 realizes the method of generating multiple thumbnails, thinkphp3.2.2 multiple_PHP tutorial
Jul 13, 2016 am 10:11 AMthinkphp3.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:
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:
I hope this article will be helpful to everyone’s PHP programming based on the ThinkPHP framework.
http://www.bkjia.com/PHPjc/930189.html

Hot Article

Hot tools Tags

Hot Article

Hot Article Tags

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

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 recover deleted contacts on WeChat (simple tutorial tells you how to recover deleted contacts)

Summary of methods to obtain administrator rights in Win11

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

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)
