今晚TP论坛的一位大哥加我了,说也遇到这个方面的问题,呵呵!想想其实很多东西都遇到了,是不是应该分享出来呢?其实自己的很多东西都是别人那来的,取之于网络用之于网络!只有大家多分享,才能够提高!
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
}
}