本文整理汇总了PHP中Option::getAttType方法的典型用法代码示例。如果您正苦于以下问题:PHP Option::getAttType方法的具体用法?PHP Option::getAttType怎么用?PHP Option::getAttType使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Option
的用法示例。
在下文中一共展示了Option::getAttType方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: emMsg
$thum_attach = $DB->fetch_array($query);
if ($thum_attach) {
if (file_exists($thum_attach['filepath'])) {
@unlink($thum_attach['filepath']) or emMsg("删除附件失败!");
}
$DB->query("DELETE FROM " . DB_PREFIX . "attachment WHERE aid = {$thum_attach['aid']} ");
}
$DB->query("UPDATE " . DB_PREFIX . "blog SET attnum=attnum-1 WHERE gid = {$attach['blogid']}");
$DB->query("DELETE FROM " . DB_PREFIX . "attachment WHERE aid = {$attach['aid']} ");
emDirect("attachment.php?action=attlib&logid={$logid}");
}
//微语图片上传
if ($action == 'upload_tw_img') {
$attach = isset($_FILES['attach']) ? $_FILES['attach'] : '';
if ($attach) {
$file_info = uploadFile($attach['name'], $attach['error'], $attach['tmp_name'], $attach['size'], Option::getAttType(), false, false);
$w = $file_info['width'];
$h = $file_info['height'];
if ($w > Option::T_IMG_MAX_W || $h > Option::T_IMG_MAX_H) {
$uppath = Option::UPLOADFILE_PATH . gmdate('Ym') . '/';
$thum = str_replace($uppath, $uppath . 'thum-', $file_info['file_path']);
if (false !== resizeImage($file_info['file_path'], $thum, Option::T_IMG_MAX_W, Option::T_IMG_MAX_H)) {
$file_info['file_path'] = $thum;
}
}
echo '{"filePath":"' . $file_info['file_path'] . '"}';
exit;
}
echo '{"filePath":""}';
exit;
}
示例2: mw_newMediaObject
function mw_newMediaObject($args)
{
global $options_cache;
escape($args[1]);
escape($args[2]);
$username = $args[1];
$password = $args[2];
$user = login($username, $password);
$file = $args[3];
if (!preg_match('/([^\\/\\:\\*\\?<>\\|]+\\.\\w{2,6})|(\\{2}[^\\/\\:\\*\\?<>\\|]+\\.\\w{2,6})/', $file['name'], $matches)) {
error_message(500, '文件错误');
}
$filename = $matches[0];
$bits = $file['bits'];
if (!empty($data["overwrite"]) && $data["overwrite"] == true) {
}
$att_type = Option::getAttType();
if (empty($filename)) {
error_message(500, '文件名错误');
}
$extension = strtolower(substr(strrchr($filename, "."), 1));
// 文件类型检测
if (!in_array($extension, $att_type)) {
error_message(500, '文件类型错误');
}
$uppath_root = substr(Option::UPLOADFILE_PATH, 1);
$uppath = $uppath_root . gmdate('Ym') . '/';
$fname = md5($filename) . gmdate('YmdHis') . '.' . $extension;
$attachpath = $uppath . $fname;
if (!is_dir($uppath_root)) {
umask(0);
$ret = @mkdir($uppath_root, 0777);
if ($ret === false) {
error_message(500, '创建文件上传目录失败');
}
}
if (!is_dir($uppath)) {
umask(0);
$ret = @mkdir($uppath, 0777);
if ($ret === false) {
error_message(500, '上传失败。文件上传目录(content/uploadfile)不可写');
}
}
$fp = @fopen($attachpath, 'wb');
if (!$fp) {
error_message(500, '文件无法写入');
}
fwrite($fp, $bits);
fclose($fp);
doAction('xmlrpc_attach_upload', $attachpath);
// resizeImage
$imtype = array('jpg', 'png', 'jpeg');
$thum = $uppath . 'thum-' . $fname;
$thum_created = true;
if (Option::get('isthumbnail') && in_array($extension, $imtype) && function_exists('ImageCreate')) {
$max_w = Option::get('att_imgmaxw');
$max_h = Option::get('att_imgmaxh');
$size = chImageSize($attachpath, $max_w, $max_h);
$newwidth = $size['w'];
$newheight = $size['h'];
$w = $size['rc_w'];
$h = $size['rc_h'];
if ($w <= $max_w && $h <= $max_h) {
$thum_created = false;
}
if ($thum_created && ($extension == 'jpeg' || $extension == 'jpg')) {
if (function_exists('imagecreatefromjpeg')) {
$img = imagecreatefromjpeg($attachpath);
} else {
$thum_created = false;
}
} elseif ($thum_created && $extension == 'png') {
if (function_exists('imagecreatefrompng')) {
$img = imagecreatefrompng($attachpath);
} else {
$thum_created = false;
}
}
if ($thum_created && function_exists('imagecopyresampled')) {
$newim = imagecreatetruecolor($newwidth, $newheight);
imagecopyresampled($newim, $img, 0, 0, 0, 0, $newwidth, $newheight, $w, $h);
} elseif ($thum_created) {
$newim = imagecreate($newwidth, $newheight);
imagecopyresized($newim, $img, 0, 0, 0, 0, $newwidth, $newheight, $w, $h);
}
if ($thum_created && ($extension == 'jpeg' || $extension == 'jpg')) {
if (!imagejpeg($newim, $attachpath)) {
$thum_created = false;
}
} elseif ($thum_created && $extension == 'png') {
if (!imagepng($newim, $attachpath)) {
$thum_created = false;
}
}
if ($thum_created) {
ImageDestroy($newim);
}
}
$img_url = $options_cache['blogurl'] . 'content/uploadfile/' . date('Ym') . '/' . $fname;
$xml = "\n <struct>\n <member>\n <name>file</name>\n <value>\n <string>{$fname}</string>\n </value>\n </member>\n <member>\n <name>url</name>\n <value>\n <string>{$img_url}</string>\n </value>\n </member>\n <member>\n <name>type</name>\n <value>\n <string></string>\n </value>\n </member>\n </struct>\n ";
//.........这里部分代码省略.........
示例3: array
$type = array('gif', 'jpg', 'jpeg', 'png');
if ($_FILES['avatar']['size'] > 0) {
$file_info = uploadFile($_FILES['avatar']['name'], $_FILES['avatar']['error'], $_FILES['avatar']['tmp_name'], $_FILES['avatar']['size'], $type, true);
if (!empty($file_info['file_path'])) {
$avatar = !empty($file_info['thum_file']) ? $file_info['thum_file'] : $file_info['file_path'];
}
}
$userData['avatar'] = $avatar;
//单位照片
$org_photo_atts = array();
$attach = isset($_FILES['attach']) ? $_FILES['attach'] : '';
if ($attach) {
$DB = MySql::getInstance();
for ($i = 0; $i < count($attach['name']); $i++) {
if ($attach['error'][$i] != 4) {
$file_info = uploadFile($attach['name'][$i], $attach['error'][$i], $attach['tmp_name'][$i], $attach['size'][$i], Option::getAttType(), false, $isthumbnail);
// 写入附件信息
$query = "INSERT INTO " . DB_PREFIX . "attachment (blogid, filename, filesize, filepath, addtime, width, height, mimetype, thumfor) VALUES ('%s','%s','%s','%s','%s','%s','%s','%s', 0)";
$query = sprintf($query, -1, $file_info['file_name'], $file_info['size'], $file_info['file_path'], time(), $file_info['width'], $file_info['height'], $file_info['mime_type']);
$DB->query($query);
$aid = $DB->insert_id();
$org_photo_atts[] = $file_info['file_path'];
}
}
}
$userData['photos'] = serialize($org_photo_atts);
$Viporg_model->addUser($userData);
$mail = new PHPMailer();
$mail->isSMTP();
$mail->SMTPDebug = 0;
$mail->Debugoutput = 'html';