本文整理汇总了PHP中cmsCore::uploadError方法的典型用法代码示例。如果您正苦于以下问题:PHP cmsCore::uploadError方法的具体用法?PHP cmsCore::uploadError怎么用?PHP cmsCore::uploadError使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类cmsCore
的用法示例。
在下文中一共展示了cmsCore::uploadError方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: md5
$filename = md5(microtime()) . '.' . $ext;
$uploaddir = PATH . '/images/banners/';
$uploadfile = $uploaddir . $filename;
if (cmsCore::moveUploadedFile($_FILES['picture']['tmp_name'], $uploadfile, $_FILES['picture']['error'])) {
if ($opt == 'submit') {
$sql = "INSERT INTO cms_banners (position, typeimg, fileurl, hits, clicks, maxhits, maxuser, user_id, pubdate, title, link, published)\n VALUES ('{$position}', '{$typeimg}', '{$filename}', 0, 0, '{$maxhits}', '{$maxuser}', 1, NOW(), '{$title}', '{$link}', '{$published}')";
$inDB->query($sql);
cmsCore::redirect('?view=components&do=config&opt=list&id=' . $id);
} else {
$fileurl = $inDB->get_field('cms_banners', "id = '{$item_id}'", 'fileurl');
@unlink($uploaddir . $fileurl);
$sql = "UPDATE cms_banners SET fileurl = '{$filename}' WHERE id = '{$item_id}'";
$inDB->query($sql);
}
} else {
cmsCore::addSessionMessage($_LANG['AD_ADDING_ERROR_TEXT'] . cmsCore::uploadError(), 'error');
cmsCore::redirectBack();
}
} elseif ($opt == 'submit') {
cmsCore::addSessionMessage($_LANG['AD_ADDING_ERROR_TEXT'], 'error');
cmsCore::redirectBack();
}
if ($opt == 'update') {
$sql = "UPDATE cms_banners\n SET position = '{$position}',\n title = '{$title}',\n published = '{$published}',\n maxhits = '{$maxhits}',\n maxuser = '{$maxuser}',\n typeimg = '{$typeimg}',\n link = '{$link}'\n WHERE id = '{$item_id}'";
$inDB->query($sql);
if (!isset($_SESSION['editlist']) || @sizeof($_SESSION['editlist']) == 0) {
cmsCore::redirect('?view=components&do=config&opt=list&id=' . $id);
} else {
cmsCore::redirect('?view=components&do=config&opt=edit&id=' . $id);
}
}
示例2: users
//.........这里部分代码省略.........
} else {
$del_flag = $opt == 'in' ? 'to_del' : 'from_del';
$id_flag = $opt == 'in' ? 'to_id' : 'from_id';
$inDB->query("UPDATE cms_user_msg SET {$del_flag}=1 WHERE {$id_flag}='{$id}'");
$inDB->query("DELETE FROM cms_user_msg WHERE to_del=1 AND from_del=1");
}
cmsCore::addSessionMessage($_LANG['MESS_ALL_DEL_OK'], 'info');
cmsCore::redirectBack();
}
//============================================================================//
//============================= Загрузка аватара ============================//
//============================================================================//
if ($do == 'avatar') {
if (!$inUser->id || $inUser->id && $inUser->id != $id) {
cmsCore::error404();
}
$inPage->setTitle($_LANG['LOAD_AVATAR']);
$inPage->addPathway($inUser->nickname, cmsUser::getProfileURL($inUser->login));
$inPage->addPathway($_LANG['LOAD_AVATAR']);
if (cmsCore::inRequest('upload')) {
cmsCore::loadClass('upload_photo');
$inUploadPhoto = cmsUploadPhoto::getInstance();
// Выставляем конфигурационные параметры
$inUploadPhoto->upload_dir = PATH . '/images/';
$inUploadPhoto->dir_medium = 'users/avatars/';
$inUploadPhoto->dir_small = 'users/avatars/small/';
$inUploadPhoto->small_size_w = $model->config['smallw'];
$inUploadPhoto->medium_size_w = $model->config['medw'];
$inUploadPhoto->medium_size_h = $model->config['medh'];
$inUploadPhoto->is_watermark = false;
$inUploadPhoto->input_name = 'picture';
$file = $inUploadPhoto->uploadPhoto($inUser->orig_imageurl);
if (!$file) {
cmsCore::addSessionMessage('<strong>' . $_LANG['ERROR'] . ':</strong> ' . cmsCore::uploadError() . '!', 'error');
cmsCore::redirect('/users/' . $id . '/avatar.html');
}
$sql = "UPDATE cms_user_profiles SET imageurl = '{$file['filename']}' WHERE user_id = '{$id}' LIMIT 1";
$inDB->query($sql);
// очищаем предыдущую запись о смене аватара
cmsActions::removeObjectLog('add_avatar', $id);
// выводим сообщение в ленту
cmsActions::log('add_avatar', array('object' => '', 'object_url' => '', 'object_id' => $id, 'target' => '', 'target_url' => '', 'description' => '<a href="' . cmsUser::getProfileURL($inUser->login) . '" class="act_usr_ava">
<img border="0" src="/images/users/avatars/small/' . $file['filename'] . '">
</a>'));
cmsCore::redirect(cmsUser::getProfileURL($inUser->login));
} else {
cmsPage::initTemplate('components', 'com_users_avatar_upload')->assign('id', $id)->display('com_users_avatar_upload.tpl');
}
}
//============================================================================//
//============================= Библиотека аватаров =========================//
//============================================================================//
if ($do == 'select_avatar') {
if (!$inUser->id || $inUser->id && $inUser->id != $id) {
cmsCore::error404();
}
$avatars_dir = PATH . "/images/users/avatars/library";
$avatars_dir_rel = "/images/users/avatars/library";
$avatars_dir_handle = opendir($avatars_dir);
$avatars = array();
while ($nextfile = readdir($avatars_dir_handle)) {
if ($nextfile != '.' && $nextfile != '..' && (mb_strstr($nextfile, '.gif') || mb_strstr($nextfile, '.jpg') || mb_strstr($nextfile, '.jpeg') || mb_strstr($nextfile, '.png'))) {
$avatars[] = $nextfile;
}
}
closedir($avatars_dir_handle);
示例3: if
cmsCore::c('images')->new_sh = $cfg['imgs_small_h'];
}
//Выставляем качество итогового изображения
cmsCore::c('images')->quality = $cfg['imgs_quality'];
$file_name = cmsCore::c('images')->resize('file', true);
if (empty($file_name) && cmsCore::uploadError()) {
cmsCore::jsonOutput(array('error' => cmsCore::uploadError(), 'msg' => ''), false);
} else if (empty($file_name)) {
cmsCore::jsonOutput(array('error' => 'UNKNOWN ERROR', 'msg' => ''), false);
}
if (!$file_name) {
cmsCore::jsonOutput(array('error' => cmsCore::uploadError(), 'msg' => ''), false);
}
$fileurl = $ym .'/'. $d .'/'. $f .'/'. $file_name;
$file_id = cmsCore::registerUploadImages($target_id, $target, $fileurl, $component);
cmsCore::jsonOutput(
array(
'small_src' => '/upload/'. $component .'/small/'. $fileurl,
'medium_src' => '/upload/'. $component .'/medium/'. $fileurl,
'big_src' => '/upload/'. $component .'/big/'. $fileurl,
'id' => $file_id,
'msg' => '/upload/'. $component .'/big/'. $fileurl // Будет удалено в скором времени
),
false
示例4: array
$source = $_FILES['Filedata']['tmp_name'];
$errorCode = $_FILES['Filedata']['error'];
if ($inCore->moveUploadedFile($source, $uploadphoto, $errorCode)) {
@img_resize($uploadphoto, $uploadthumb['small'], 96, 96, true);
@img_resize($uploadphoto, $uploadthumb['medium'], 600, 600, false, false);
if ($model->config['watermark']) {
@img_add_watermark($uploadthumb['medium']);
}
@unlink($uploadphoto);
$model->addUploadedPhoto($user_id, array('filename' => $realfile, 'imageurl' => $filename));
if (cmsCore::inRequest('upload')) {
cmsCore::redirect('/users/' . $inUser->login . '/photos/submit');
}
} else {
header("HTTP/1.1 500 Internal Server Error");
echo cmsCore::uploadError();
}
exit(0);
}
if ($pdo == 'submitphotos') {
if (!$inUser->id) {
cmsCore::error404();
}
$usr = cmsUser::getShortUserData($login);
if (!$usr) {
cmsCore::error404();
}
if ($usr['id'] != $inUser->id && !$inUser->is_admin) {
cmsCore::error404();
}
$photos = $model->getUploadedPhotos($usr['id']);
示例5: getFieldsInputValues
/**
* Проверяет значения формы
* @param int $form_id ID формы
* @return array
*/
public static function getFieldsInputValues($form_id)
{
// Получаем данные без mysqli_real_escape_string
$form_array = cmsCore::request('field', 'array');
if (!$form_array) {
return array();
}
$formObj = new self($form_id, $form_array);
if (!$formObj->form || !$formObj->form_fields) {
return array();
}
global $_LANG;
$inUser = cmsUser::getInstance();
$output = array();
// Заполняем выходной массив значений
// $output['values'] массив значений полей
// $output['errors'] массив ошибок полей
foreach ($formObj->form_fields as $field) {
// Значение поля
$field_value = array_key_exists($field['id'], $formObj->values) ? $formObj->values[$field['id']] : '';
$error = '';
// проверяем заполненность текстового поля если нужно
if ($field['mustbe'] && !$field_value && $field['kind'] != 'file') {
$error = $_LANG['FIELD'] . ' "' . $field['title'] . '" ' . $_LANG['MUST_BE_FILLED'];
} else {
cmsUser::sessionPut('form_last_' . $formObj->form_id . '_' . $field['id'], htmlspecialchars($field_value));
}
// Загружаем файл если он есть в форме
if ($field['kind'] == 'file') {
// старые значения если есть
$old_url = $field_value['url'];
$old_name = $field_value['name'];
$output['values'][$field['id']] = array();
if (!$_FILES['field']['name'][$field['id']]) {
// Поле обязательно для заполнения?
if ($field['mustbe'] && !$old_url) {
$error = $_LANG['FIELD'] . ' "' . $field['title'] . '" ' . $_LANG['MUST_BE_FILLED'];
} else {
// если пришел флаг на удаление
if (isset($field_value['delete'])) {
$formObj->deleteFile($old_url);
$old_url = '';
$old_name = '';
}
$output['values'][$field['id']] = array('name' => $old_name, 'url' => $old_url);
}
} else {
// директория загрузки
$upload_dir = PATH . '/upload/forms/' . $form_id . '/' . $inUser->id;
@mkdir($upload_dir, 0777, true);
@chmod($upload_dir, 0777);
// проверяем расширение файла
$maytypes = explode(',', $field['config']['ext']);
$ext = mb_strtolower(pathinfo($_FILES['field']['name'][$field['id']], PATHINFO_EXTENSION));
if (!in_array($ext, $maytypes)) {
$error = $_LANG['ERROR_TYPE_FILE'] . $field['config']['ext'];
}
// имя файла
$file_name = cmsCore::strToURL(pathinfo($_FILES['field']['name'][$field['id']], PATHINFO_FILENAME));
$dest = $upload_dir . '/' . $file_name . uniqid() . '.' . $ext;
if (!$error) {
if (!cmsCore::moveUploadedFile($_FILES['field']['tmp_name'][$field['id']], $dest, $_FILES['field']['error'][$field['id']])) {
$error = cmsCore::uploadError();
} else {
$formObj->deleteFile($old_url);
$output['values'][$field['id']] = array('name' => $file_name, 'url' => str_replace(PATH, '', $dest));
}
}
}
} else {
// Заполняем массив значений полей, ключи массива id поля
$output['values'][$field['id']] = $field['config']['max'] ? mb_substr(strip_tags($field_value), 0, $field['config']['max']) : strip_tags($field_value);
}
// Заполняем массив ошибок
$output['errors'][$field['id']] = $error;
}
// если были ошибки, удаляем загруженный файл, если он есть
if (!empty($dest)) {
foreach ($output['errors'] as $field_error) {
if ($field_error) {
@unlink($dest);
break;
}
}
}
return $output;
}