• 核桃说笔记2


    php上传头像修改上传头像操作
    function
    editimg() { /*echo "<pre>"; print_r( $_FILES);die;*/ $navtitle = "修改个人头像"; if (isset ( $_FILES ["userimage"] )) { $uid = intval ( $this->uri->segment ( 3 ) ); $avatardir = "/data/avatar/"; $extname = extname ( $_FILES ["userimage"] ["name"] ); if (! isimage ( $extname )) $this->message ( "图片扩展名不正确!", 'user/editimg' ); $upload_tmp_file = FCPATH . 'data/tmp/user_avatar_' . $uid . '.' . $extname; $uid = abs ( $uid ); $uid = sprintf ( "%09d", $uid ); $dir1 = $avatardir . substr ( $uid, 0, 3 ); $dir2 = $dir1 . '/' . substr ( $uid, 3, 2 ); $dir3 = $dir2 . '/' . substr ( $uid, 5, 2 ); (! is_dir ( FCPATH . $dir1 )) && forcemkdir ( FCPATH . $dir1 ); (! is_dir ( FCPATH . $dir2 )) && forcemkdir ( FCPATH . $dir2 ); (! is_dir ( FCPATH . $dir3 )) && forcemkdir ( FCPATH . $dir3 ); $smallimg = $dir3 . "/small_" . $uid . '.' . $extname; if (move_uploaded_file ( $_FILES ["userimage"] ["tmp_name"], $upload_tmp_file )) { $avatar_dir = glob ( FCPATH . $dir3 . "/small_{$uid}.*" ); foreach ( $avatar_dir as $imgfile ) { if (strtolower ( $extname ) != extname ( $imgfile )) unlink ( $imgfile ); } image_resize ( $upload_tmp_file, FCPATH . $smallimg, 85, 85, 1 ); $this->message ( '修改头像成功', 'user' ); } } else { if ($this->setting ["ucenter_open"]) { $this->load->model ( 'ucenter_model' ); $imgstr = $this->ucenter_model->set_avatar ( $this->user ['uid'] ); } } include template ( "editimg" ); }

    未完待续。。。。。。。。。

  • 相关阅读:
    批处理学习总结
    深搜广搜
    罗塔的一篇回忆埃尔德什的文字
    一个有意思的东西(挖坑)
    人格风骨出尘俗 道德文章传后人(转载)
    2015年数学日历
    一道关于将弧翻折的问题
    努力要做的是理解,而不是死记硬背
    在博客中使用align*环境
    测试TeX代码的网址
  • 原文地址:https://www.cnblogs.com/yszr/p/10748577.html
Copyright © 2020-2023  润新知