dedecms图片上传函数
2024-08-25 14:55:16
/**
* 图片上传类
* @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 - );
return $subdestination;
}
最新文章
- flash中设置文本字体样式
- 判断字符串的首字母 ---------startsWith
- UIBarButtonItem的创建
- python django 与数据库的交互
- NDK
- hbase查询,scan详解
- Html5 Canvas动画旋转的小方块;
- 快速开发 jQuery 插件的 10 大技巧(转)
- 如何将CELERY放到后台执行?
- PowerDesigner使用总结 转
- hibernate通过配置文件生成数据库信息
- 关键字中mysql数据库查询条件带中文无结果解决办法
- CSS float:right 在IE浏览器下换行
- iOS -- Effective Objective-C 阅读笔记 (6)
- Jenkins中使用GitLab的配置
- EasyUI动态修改easyui-textbox验证信息
- 第四十一课 KMP子串查找算法
- mysql 事务中如果有sql语句出错,会导致自动回滚吗?
- Graphviz 环境变量设置
- Python学习笔记:算法的重要性
热门文章
- 深入__proto__和prototype的区别和联系
- deno学习二 基本代码
- Web开发需要常见的问题
- C#细说多线程(下)
- 【BZOJ4445】[SCOI2015]小凸想跑步(半平面交)
- emacs之配置7,tabbar插件
- MySQL性能调优 – 你必须了解的15个重要变量
- LLMNR欺骗工具Responder
- Check failed: mdb_status == 0 (2 vs. 0) No such file or directory
- 【POJ】1062 昂贵的聘礼 (最短路)