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;
    }
  • 相关阅读:
    C/C++多文件之间的变量定义
    PKU POJ 2186 Popular Cows 强连通分量
    重载函数
    ZOJ 2763 Prison Break
    201357 训练赛总结
    hdu 4467 Graph 构造
    201356 训练赛总结
    201353 NEERC 2012, Eastern subregional contest
    2013512 CF 183 总结
    一道动态规划
  • 原文地址:https://www.cnblogs.com/xiaobiaomei/p/8288587.html
Copyright © 2011-2022 走看看