/**
* 图片上传类
* @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; }