Discuz教程网

[插件制作] discuz的image类使用

[复制链接]
authicon dly 发表于 2012-8-3 20:22:35 | 显示全部楼层 |阅读模式
discuz的image类使用
  1. <input type="attach" name="file">//文件域的名字
  2. //处理方法
  3. //新图
  4. if(!empty($_FILES['attach']['tmp_name']) && is_uploaded_file($_FILES['attach']['tmp_name'])){
  5. $query = DB::query("select filename,filepath from pre_home_hall_pic where picid =$picid ");
  6. while ($value = DB::fetch($query)) {
  7. $oldfilepath=$value['filepath'];
  8. $filename =$value['filename'];
  9. }
  10. $file_info = pathinfo($_FILES['attach']['name']);
  11. $ext = $file_info['extension'];// 取扩展名

  12. $filepath = dirname($oldfilepath).'/'.date('His').strtolower(random(16)).'.'.$ext;//随机重命名
  13. $uploadpath = 'data/attachment/hall/'.$filepath;
  14. if(!is_dir('data/attachment/hall/'.$oldfilepath)){
  15. unlink('data/attachment/hall/'.$oldfilepath);
  16. unlink('data/attachment/hall/'.$oldfilepath.'');
  17. }
  18. $res = move_uploaded_file($_FILES['attach']['tmp_name'], $uploadpath);
  19. if($res){
  20. require_once libfile('class/image');
  21. $image = new image();
  22. $result = $image->Thumb($uploadpath, '', 140, 140, 1);
  23. }
  24. $data['filename'] = $_FILES['attach']['name'];
  25. $data['filepath'] = $filepath;
  26. }
  27. DB::update('home_hall_pic', $data, $wherearr);
复制代码



上一篇:Discuz X2论坛的机器人程序,实现了登录,签到,发贴及回帖等功能
下一篇:仿discuz 上传头像
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

1314学习网 ( 浙ICP备10214163号 )

GMT+8, 2025-5-2 03:46

Powered by Discuz! X3.4

© 2001-2013 Comsenz Inc.

快速回复 返回顶部 返回列表