本文整理汇总了PHP中CFile::img_to_small方法的典型用法代码示例。如果您正苦于以下问题:PHP CFile::img_to_small方法的具体用法?PHP CFile::img_to_small怎么用?PHP CFile::img_to_small使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CFile
的用法示例。
在下文中一共展示了CFile::img_to_small方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: array
if (!isNulArray($img->error)) {
if (is_array($img->error)) {
$err = $img->error[0];
} else {
$err = $img->error;
}
$error = true;
$pictname = $prevname = '';
} else {
if (in_array($img->getext(), $GLOBALS['disallowed_array'])) {
$err = 'Недопустимый тип файла';
$error = true;
} else {
if (in_array($img->getext(), $GLOBALS['graf_array']) && strtolower($img->getext()) != 'swf' && strtolower($img->getext()) != 'flv') {
// Делаем превью.
$pict_added = $img->img_to_small('sm_' . $pictname, array('width' => 200, 'height' => 200, 'less' => 0));
if (!isNulArray($img->error)) {
$error = true;
$pictname = $prevname = '';
} elseif ($pict_added) {
$prevname = 'sm_' . $pictname;
}
} else {
$pict_added = true;
}
}
}
} elseif (strlen($img->tmp_name) != 0) {
$err = 'Пустой файл';
$error = true;
} elseif ($img->error) {
示例2: saveAction
//.........这里部分代码省略.........
} else {
$max_image_size = array('width' => 470, 'height' => 1000, 'less' => 0);
}
$login = $_SESSION["login"];
if ($filesBefore) {
foreach ($filesBefore as $file) {
if (!$file->temp) {
continue;
}
$b_file = new CFile("temp/" . $file->id);
if ($b_file->id > 0) {
$b_file->Rename("users/" . substr($login, 0, 2) . "/" . $login . "/upload" . "/" . $file->id);
$ext = $b_file->getext();
if (in_array($ext, $GLOBALS['graf_array'])) {
$is_image = TRUE;
} else {
$is_image = FALSE;
}
$b_file->max_size = blogs::MAX_FILE_SIZE;
$b_file->proportional = 1;
if (!isNulArray($file->error)) {
// $error_flag = 1;
//print_r($file->error);
$alert[3] = "Один или несколько файлов не удовлетворяют условиям загрузки.";
// break;
} else {
if ($is_image && $ext != 'swf' && $ext != 'flv') {
if (!$b_file->image_size['width'] || !$b_file->image_size['height']) {
// $error_flag = 1;
$alert[3] = 'Невозможно уменьшить картинку';
break;
}
if (!$error_flag && ($b_file->image_size['width'] > $max_image_size['width'] || $b_file->image_size['height'] > $max_image_size['height'])) {
if (!$b_file->img_to_small("sm_" . $file->id, $max_image_size)) {
// $error_flag = 1;
$alert[3] = 'Невозможно уменьшить картинку.';
break;
} else {
$b_file->tn = 2;
$b_file->p_name = "sm_" . $file->id;
}
} else {
$b_file->tn = 1;
}
} else {
if ($ext == 'flv') {
$b_file->tn = 2;
} else {
$b_file->tn = 0;
}
}
if ($alert[3]) {
$validate_errors['files'] = $alert[3];
}
$files[] = $b_file;
}
}
}
}
}
//global $session;
if (is_array($files) && sizeof($files)) {
$asql = '';
foreach ($files as $file) {
//currval('corporative_blog_id_seq')
if ($file->name) {
示例3: elseif
} elseif (isset($_FILES['attach'])) {
$file->max_image_size = array('width' => 720, 'height' => 1000, 'less' => 1);
}
if ($file->name && $file->error) {
$alert = $file->error[0];
} else {
$file->MoveUploadedFile('about/interview/');
if (!isNulArray($file->error)) {
$alert = 'Файл не удовлетворяет условиям загрузки';
}
}
$fileid = $file->id;
$filepath = $file->path;
$filename = $file->name;
if (isset($_FILES['main_foto']) && !isset($alert)) {
$resf = $file->img_to_small('sm_' . $file->name, array('width' => 180, 'height' => 180), true);
if (!$resf) {
$alert = $file->error[0];
}
}
if (isset($alert)) {
$result['errorMessage'] = iconv('CP1251', 'UTF-8', $alert);
} else {
$result['success'] = true;
$result['file'] = array('id' => $fileid, 'path' => $filepath, 'fname' => $filename, 'is_main' => $is_main);
}
echo json_encode($result);
exit;
break;
case 'get-interview':
if (!hasPermissions('interviews')) {
示例4: elseif
if ($imageTypes) {
// то файл должен быть графическим
$file->_getImageSize($file->tmp_name);
if (!$file->image_size['type'] || !in_array($file->image_size['type'], $imageTypes)) {
$err = 'Недопустимый формат файла';
}
}
if (!$err) {
$filename = $file->MoveUploadedFile($sFullDir);
$fileid = $file->id;
$err = $file->StrError();
if (!$err && $type == 'work_prev' && (!in_array($file->getext(), $GLOBALS['graf_array']) || strtolower($file->getext()) == 'swf' || strtolower($file->getext()) == 'flv')) {
$err = 'Недопустимый тип файла';
}
if ($type == 'photo' || $type == 'logo') {
if (!$err && !$file->img_to_small('sm_' . $filename, array('width' => 50, 'height' => 50))) {
$err .= 'Невозможно уменьшить картинку.';
}
}
}
} elseif (!$err) {
// логотип проекта
require_once $_SERVER['DOCUMENT_ROOT'] . '/classes/projects.php';
$tmpPrj = new tmp_project($pkey);
$prj = $tmpPrj->init(1);
$err = $tmpPrj->setLogo($file);
$tmpPrj->fix();
$logo = $tmpPrj->getLogo();
$logourl = WDCPREFIX . '/' . $logo['path'] . $logo['name'];
}
}
示例5: saveAction
//.........这里部分代码省略.........
} else {
$max_image_size = array('width' => 470, 'height' => 1000, 'less' => 0);
}
$login = $_SESSION['login'];
if ($filesBefore) {
foreach ($filesBefore as $file) {
if (!$file->temp) {
continue;
}
$b_file = new CFile('temp/' . $file->id);
if ($b_file->id > 0) {
$b_file->Rename('users/' . substr($login, 0, 2) . '/' . $login . '/upload' . '/' . $file->id);
$ext = $b_file->getext();
if (in_array($ext, $GLOBALS['graf_array'])) {
$is_image = true;
} else {
$is_image = false;
}
$b_file->max_size = blogs::MAX_FILE_SIZE;
$b_file->proportional = 1;
if (!isNulArray($file->error)) {
// $error_flag = 1;
//print_r($file->error);
$alert[3] = 'Один или несколько файлов не удовлетворяют условиям загрузки.';
// break;
} else {
if ($is_image && $ext != 'swf' && $ext != 'flv') {
if (!$b_file->image_size['width'] || !$b_file->image_size['height']) {
// $error_flag = 1;
$alert[3] = 'Невозможно уменьшить картинку';
break;
}
if (!$error_flag && ($b_file->image_size['width'] > $max_image_size['width'] || $b_file->image_size['height'] > $max_image_size['height'])) {
if (!$b_file->img_to_small('sm_' . $file->id, $max_image_size)) {
// $error_flag = 1;
$alert[3] = 'Невозможно уменьшить картинку.';
break;
} else {
$b_file->tn = 2;
$b_file->p_name = 'sm_' . $file->id;
}
} else {
$b_file->tn = 1;
}
} elseif ($ext == 'flv') {
$b_file->tn = 2;
} else {
$b_file->tn = 0;
}
if ($alert[3]) {
$validate_errors['files'] = $alert[3];
}
$files[] = $b_file;
}
}
}
}
}
//global $session;
if (is_array($files) && sizeof($files)) {
$asql = '';
foreach ($files as $file) {
//currval('corporative_blog_id_seq')
if ($file->name) {
$asql .= ", ({$id}, '{$file->name}', '{$file->tn}')";
}