zoukankan      html  css  js  c++  java
  • 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;
    }
  • 相关阅读:
    浅谈系统调用与库函数
    由代码到可执行程序----浅谈程序的编译链接
    初识信号---进程间的交流
    内部排序总结之----选择类排序(选择、堆)
    僵死进程
    父子进程那些事儿
    fok函数
    面试-css样式
    面试-javascript知识
    面试--数据库
  • 原文地址:https://www.cnblogs.com/xiaobiaomei/p/8288587.html
Copyright © 2011-2022 走看看