• dedecms图片上传函数


    
    
    /**
    * 图片上传类
    * @param $file上传图片信息
    * @param $ty
    */
    function upload_pic($file, $ty) {
        if (!is_uploaded_file($file["tmp_name"])) {//是否存在文件
            tcmc::ShowMsg("图片不存在!", "turntable_index.php?op=index");
        }
        if (!in_array($file["type"], array('image/jpg', 'image/jpeg', 'image/png'))) {//检查文件类型
            tcmc::ShowMsg("文件类型不符!", "turntable_index.php?op=index");
        }
        $destination_folder = CMS_ROOT . 'uploads/miaosha/';
        if (!file_exists($destination_folder)) {
            mkdir($destination_folder);
        }
        $pinfo = pathinfo($file["name"]);
        $ftype = $pinfo['extension'];
        $destination = $destination_folder . "turntable_" . $ty . time() . "." . $ftype;
        $filename = $file["tmp_name"];
        if (file_exists($destination) && $overwrite != true) {
            tcmc::ShowMsg("同名文件已经存在了!", "turntable_index.php?op=index");
        }
        if (!move_uploaded_file($filename, $destination)) {
            tcmc::ShowMsg("移动文件出错1!", "turntable_index.php?op=index");
        }
    
        $len = strlen(CMS_ROOT);
        $subdestination = substr($destination, $len - 1);
        return $subdestination;
    }
  • 相关阅读:
    Java(二)
    JS === 关于getElementsByClassName()
    JS === 简易放大镜
    JS === 拖拽盒子
    JS === 实现多个光标跟随事件
    JS === 实现回到顶部
    JS === 实现通过点击td 跳转相应的图片
    final、static关键字
    java面向对象——构造方法
    java面向对象——多态
  • 原文地址:https://www.cnblogs.com/xiaobiaomei/p/8288587.html
Copyright © 2020-2023  润新知