THINKPHP+JS realizes the implementation of zoom picture screenshot_PHP tutorial

WBOY
Release: 2016-07-21 15:40:28
Original
957 people have browsed it

Author: Yang Xinqi

Original link: http://www.cnblogs.com/scotoma/archive/2010/03/05/1679477.html

Tonight, a big brother from the TP forum added me, saying that he also encountered this problem, haha! Come to think of it, I have encountered many things, should I share it? In fact, many of my things came from others, taken from the Internet and used on the Internet! Only by sharing more can we improve!

How to implement it

Upload pictures -- Save and display pictures -- JS gets thumbnail parameters -- Submit location parameters -- Image scaling and saving class processing pictures -- Save captured pictures -- Update database -- Jump

The last few screenshots

THINKPHP+JS realizes the implementation of zoom picture screenshot_PHP tutorial

The following is an example screenshot

THINKPHP+JS realizes the implementation of zoom picture screenshot_PHP tutorial

THINKPHP+JS realizes the implementation of zoom picture screenshot_PHP tutorial

THINKPHP+JS realizes the implementation of zoom picture screenshot_PHP tutorial

Main implementation code

Copy code The code is as follows:

public function cutimg()
{
$result = $this->upload('temp');
if (!is_array($result))
{
$this->redirect('index');
}
else
{
$this->assign('imgurl', '__ROOT__/' . C('ATTACHDIR') . '/temp/' . $result[0]['savename' ]);
$this->assign('imgname', $result[0]['savename']);
$this->display();
}
}

Copy code The code is as follows:

public function setavatar()
{
if (!empty($_REQUEST['cut_pos']))
{
// import('ORG.Util.ImageResize');
require('ImageResize.class.php');
$imgresize = new ImageResize();
// use the full path
$url = C('ATTACHDIR') . '/temp/' . trim($_POST['imgname']);
$imgresize->load($url);
dump($url);
$posary = explode(',', $_REQUEST['cut_pos']);
foreach($posary as $ k => $v)

$posary[$k] = intval($v);

if ($posary[2] > 0 && $posary[3] > 0) $imgresize->resize($posary[2], $posary[3]);

dump($posary);
// create filename rule
$uico = time( ) . '.jpg';
dump($uico);
$path = C('AVATAR');
// save 120*120 image
$imgresize->cut(120 , 120, intval($posary[0]), intval($posary[1]));
$large = 'l_' . $uico;
$imgresize->save($path . $large );

echo '';
// update database
}
else
{
// error reporting
}
}

Source code download address: Click to download other ones and improve them yourself. Please visit the TP framework required to run Download http://www.thinkphp.cn, and then download the expansion pack, because the Upload class is used!

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/321362.htmlTechArticleAuthor: Yang Xinqi Original link: http://www.cnblogs.com/scotoma/archive/2010/03/ 05/1679477.html A big brother from the TP forum added me tonight, saying that he also encountered this problem, haha...
source:php.cn
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!