作者 刘朕
1 个管道 的构建 通过 耗费 1 秒

页面生成图片优化

... ... @@ -15,6 +15,7 @@ use app\portal\model\IndentModel;
use cmf\controller\WeChatBaseController;
use think\Db;
use think\Image;
use think\Session;
class OrderSalesmanController extends WeChatBaseController
{
... ... @@ -266,6 +267,10 @@ class OrderSalesmanController extends WeChatBaseController
$new_img->thumb($width,$height - intval($top) * 2,5);
$new_img->thumb($width/2,($height - intval($top) * 2)/2);
$new_img->save('./upload/'.$img_url,'jpg',100);
$session_img = Session::get('img_url');
if(file_exists('./upload/'.$session_img)) {
@unlink('./upload/'.$session_img);
}
$this->success('成功','',cmf_get_asset_url($img_url));
}
}
... ... @@ -289,9 +294,12 @@ class OrderSalesmanController extends WeChatBaseController
//检查是否有该文件夹,如果没有就创建,并给予最高权限
mkdir($new_file, 0777,true);
}
$new_file = $new_file.cmf_get_current_user_id().".{$type}";
$time = time();
$new_file = $new_file.cmf_get_current_user_id().$time.".{$type}";
if (file_put_contents($new_file, base64_decode(str_replace($result[1], '', $base64_image_content)))){
return $file_path.cmf_get_current_user_id().".{$type}";
$file = $file_path.cmf_get_current_user_id().$time.".{$type}";
Session::set('img_url',$file);
return $file;
}else{
return false;
}
... ...