本文整理匯總了PHP中cls_image::upload_image方法的典型用法代碼示例。如果您正苦於以下問題:PHP cls_image::upload_image方法的具體用法?PHP cls_image::upload_image怎麽用?PHP cls_image::upload_image使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類cls_image
的用法示例。
在下文中一共展示了cls_image::upload_image方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: wxch_upload_file
function wxch_upload_file($upload)
{
$image = new cls_image();
$res = $image->upload_image($upload);
if ($res) {
return $res;
} else {
return false;
}
}
示例2: trim
} else {
$ad_link = !empty($_POST['ad_link2']) ? trim($_POST['ad_link2']) : '';
}
/* 獲得廣告的開始時期與結束日期 */
$start_time = local_strtotime($_POST['start_time']);
$end_time = local_strtotime($_POST['end_time']);
/* 查看廣告名稱是否有重複 */
$sql = "SELECT COUNT(*) FROM " . $ecs->table('ad') . " WHERE ad_name = '{$ad_name}'";
if ($db->getOne($sql) > 0) {
$link[] = array('text' => $_LANG['go_back'], 'href' => 'javascript:history.back(-1)');
sys_msg($_LANG['ad_name_exist'], 0, $link);
}
/* 添加圖片類型的廣告 */
if ($_POST['media_type'] == '0') {
if (isset($_FILES['ad_img']['error']) && $_FILES['ad_img']['error'] == 0 || !isset($_FILES['ad_img']['error']) && isset($_FILES['ad_img']['tmp_name']) && $_FILES['ad_img']['tmp_name'] != 'none') {
$ad_code = basename($image->upload_image($_FILES['ad_img'], 'afficheimg'));
}
if (!empty($_POST['img_url'])) {
$ad_code = $_POST['img_url'];
}
if ((isset($_FILES['ad_img']['error']) && $_FILES['ad_img']['error'] > 0 || !isset($_FILES['ad_img']['error']) && isset($_FILES['ad_img']['tmp_name']) && $_FILES['ad_img']['tmp_name'] == 'none') && empty($_POST['img_url'])) {
$link[] = array('text' => $_LANG['go_back'], 'href' => 'javascript:history.back(-1)');
sys_msg($_LANG['js_languages']['ad_photo_empty'], 0, $link);
}
} elseif ($_POST['media_type'] == '1') {
if (isset($_FILES['upfile_flash']['error']) && $_FILES['upfile_flash']['error'] == 0 || !isset($_FILES['upfile_flash']['error']) && isset($_FILES['ad_img']['tmp_name']) && $_FILES['upfile_flash']['tmp_name'] != 'none') {
/* 檢查文件類型 */
if ($_FILES['upfile_flash']['type'] != "application/x-shockwave-flash") {
$link[] = array('text' => $_LANG['go_back'], 'href' => 'javascript:history.back(-1)');
sys_msg($_LANG['upfile_flash_type'], 0, $link);
}
示例3: array
if (!$image->check_img_type($_FILES['goods_img']['type'])) {
sys_msg($_LANG['invalid_goods_img'], 1, array(), false);
}
}
}
$goods_img = '';
// 初始化商品圖片
$goods_thumb = '';
// 初始化商品縮略圖
$original_img = '';
// 初始化原始圖片
$old_original_img = '';
// 初始化原始圖片舊圖
// 如果上傳了商品圖片,相應處理
if ($_FILES['goods_img']['tmp_name'] != '' && $_FILES['goods_img']['tmp_name'] != 'none') {
$original_img = $image->upload_image($_FILES['goods_img']);
// 原始圖片
if ($original_img === false) {
sys_msg($image->error_msg(), 1, array(), false);
}
$goods_img = $original_img;
// 商品圖片
/* 複製一份相冊圖片 */
$img = $original_img;
// 相冊圖片
$pos = strpos(basename($img), '.');
$newname = dirname($img) . '/' . $image->random_filename() . substr(basename($img), $pos);
if (!copy('../' . $img, '../' . $newname)) {
sys_msg('fail to copy file: ' . realpath('../' . $img), 1, array(), false);
}
$img = $newname;
示例4: array
$smarty->assign('card', $card);
$smarty->assign('ur_here', $_LANG['card_add']);
$smarty->assign('action_link', array('text' => $_LANG['07_card_list'], 'href' => 'card.php?act=list'));
$smarty->assign('form_action', 'insert');
assign_query_info();
$smarty->display('card_info.htm');
} elseif ($_REQUEST['act'] == 'insert') {
/* 權限判斷 */
admin_priv('card_manage');
/*檢查包裝名是否重複*/
$is_only = $exc->is_only('card_name', $_POST['card_name']);
if (!$is_only) {
sys_msg(sprintf($_LANG['cardname_exist'], stripslashes($_POST['card_name'])), 1);
}
/*處理圖片*/
$img_name = basename($image->upload_image($_FILES['card_img'], "cardimg"));
/*插入數據*/
$sql = "INSERT INTO " . $ecs->table('card') . "(card_name, card_fee, free_money, card_desc, card_img)\r\n VALUES ('{$_POST['card_name']}', '{$_POST['card_fee']}', '{$_POST['free_money']}', '{$_POST['card_desc']}', '{$img_name}')";
$db->query($sql);
admin_log($_POST['card_name'], 'add', 'card');
/*添加鏈接*/
$link[0]['text'] = $_LANG['continue_add'];
$link[0]['href'] = 'card.php?act=add';
$link[1]['text'] = $_LANG['back_list'];
$link[1]['href'] = 'card.php?act=list';
sys_msg($_POST['card_name'] . $_LANG['cardadd_succeed'], 0, $link);
} elseif ($_REQUEST['act'] == 'edit') {
/* 權限判斷 */
admin_priv('card_manage');
$sql = "SELECT card_id, card_name, card_fee, free_money, card_desc, card_img FROM " . $ecs->table('card') . " WHERE card_id='{$_REQUEST['id']}'";
$card = $db->GetRow($sql);
示例5: array
$status = $_POST['status'];
$users =& init_users();
if (!$users->edit_user(array('username' => $username, 'password' => $password, 'email' => $email, 'gender' => $sex, 'bday' => $birthday), 1)) {
if ($users->error == ERR_EMAIL_EXISTS) {
$msg = $_LANG['email_exists'];
} else {
$msg = $_LANG['edit_user_failed'];
}
sys_msg($msg, 1);
}
if (!empty($password)) {
$sql = "UPDATE " . $ecs->table('users') . "SET `ec_salt`='0' WHERE user_name= '" . $username . "'";
$db->query($sql);
}
if (isset($_FILES['face_card']) && $_FILES['face_card']['tmp_name'] != '') {
$face_card = $image->upload_image($_FILES['face_card']);
if ($face_card === false) {
sys_msg($image->error_msg(), 1, array(), false);
}
}
if (isset($_FILES['back_card']) && $_FILES['back_card']['tmp_name'] != '') {
$back_card = $image->upload_image($_FILES['back_card']);
if ($back_card === false) {
sys_msg($image->error_msg(), 1, array(), false);
}
}
$sql = "update " . $ecs->table('users') . " set `real_name`='{$real_name}',`card`='{$card}',`country`='{$country}',`province`='{$province}',`city`='{$city}',`district`='{$district}',`address`='{$address}',`status`='{$status}' where user_name = '" . $username . "'";
$db->query($sql);
if ($face_card != '') {
$sql = "update " . $ecs->table('users') . " set `face_card` = '{$face_card}' where user_name = '" . $username . "'";
$db->query($sql);
示例6: intval
$cat['cat_id'] = !empty($_POST['cat_id']) ? intval($_POST['cat_id']) : 0;
$cat['parent_id'] = !empty($_POST['parent_id']) ? intval($_POST['parent_id']) : 0;
$cat['sort_order'] = !empty($_POST['sort_order']) ? intval($_POST['sort_order']) : 0;
$cat['keywords'] = !empty($_POST['keywords']) ? trim($_POST['keywords']) : '';
$cat['cat_desc'] = !empty($_POST['cat_desc']) ? $_POST['cat_desc'] : '';
$cat['measure_unit'] = !empty($_POST['measure_unit']) ? trim($_POST['measure_unit']) : '';
$cat['cat_name'] = !empty($_POST['cat_name']) ? trim($_POST['cat_name']) : '';
$cat['show_in_nav'] = !empty($_POST['show_in_nav']) ? intval($_POST['show_in_nav']) : 0;
$cat['style'] = !empty($_POST['style']) ? trim($_POST['style']) : '';
$cat['style_moban'] = !empty($_POST['style_moban']) ? trim($_POST['style_moban']) : '';
$cat['is_show'] = !empty($_POST['is_show']) ? intval($_POST['is_show']) : 0;
$cat['grade'] = !empty($_POST['grade']) ? intval($_POST['grade']) : 0;
$cat['filter_attr'] = !empty($_POST['filter_attr']) ? implode(',', array_unique(array_diff($_POST['filter_attr'], array(0)))) : 0;
$cat['cat_recommend'] = !empty($_POST['cat_recommend']) ? $_POST['cat_recommend'] : array();
if (isset($_FILES['cat_img']) && $_FILES['cat_img']['tmp_name'] != '') {
$cat['cat_img'] = $image->upload_image($_FILES['cat_img']);
}
if (cat_exists($cat['cat_name'], $cat['parent_id'])) {
/* 同級別下不能有重複的分類名稱 */
$link[] = array('text' => $_LANG['go_back'], 'href' => 'javascript:history.back(-1)');
sys_msg($_LANG['catname_exist'], 0, $link);
}
if ($cat['grade'] > 10 || $cat['grade'] < 0) {
/* 價格區間數超過範圍 */
$link[] = array('text' => $_LANG['go_back'], 'href' => 'javascript:history.back(-1)');
sys_msg($_LANG['grade_error'], 0, $link);
}
/* 入庫的操作 */
if ($db->autoExecute($hhs->table('category'), $cat) !== false) {
$cat_id = $db->insert_id();
insert_cat_recommend($cat['cat_recommend'], $cat_id);
示例7: elseif
}
if ($row['goods_img'] != '' && is_file('../' . $row['goods_img'])) {
@unlink('../' . $row['goods_img']);
}
if ($row['original_img'] != '' && is_file('../' . $row['original_img'])) {
/* 先不處理,以防止程序中途出錯停止 */
//$old_original_img = $row['original_img']; //記錄舊圖路徑
}
/* 清除原來商品圖片 */
if ($proc_thumb === false) {
get_image_path($_REQUEST[goods_id], $row['goods_img'], false, 'goods', true);
get_image_path($_REQUEST[goods_id], $row['goods_thumb'], true, 'goods', true);
}
}
if (empty($is_url_goods_img)) {
$original_img = $image->upload_image($_FILES['goods_img']);
// 原始圖片
} elseif (copy(trim($_POST['goods_img_url']), ROOT_PATH . 'temp/' . basename($_POST['goods_img_url']))) {
$original_img = 'temp/' . basename($_POST['goods_img_url']);
}
if ($original_img === false) {
sys_msg($image->error_msg(), 1, array(), false);
}
$goods_img = $original_img;
// 商品圖片
/* 複製一份相冊圖片 */
/* 添加判斷是否自動生成相冊圖片 */
if ($_CFG['auto_generate_gallery']) {
$img = $original_img;
// 相冊圖片
$pos = strpos(basename($img), '.');
示例8: elseif
} else {
sys_msg('刪除菜單失敗!', 0, $link);
}
} elseif ($_REQUEST['act'] == 'add') {
$smarty->assign('from_act', 'add_menu');
$smarty->assign('action_link', array('text' => '菜單列表', 'href' => 'menu.php?act=list'));
$smarty->display('menu_info.htm');
} elseif ($_REQUEST['act'] == 'add_menu') {
include_once ROOT_PATH . '/includes/cls_image.php';
$image = new cls_image($_CFG['bgcolor']);
$menu_name = $_REQUEST['menu_name'];
$menu_url = $_REQUEST['menu_url'];
$sort = $_REQUEST['sort'];
if (isset($_FILES['menu_img']) && $_FILES['menu_img']['tmp_name'] != '' && isset($_FILES['menu_img']['tmp_name']) && $_FILES['menu_img']['tmp_name'] != 'none') {
// 上傳了,直接使用,原始大小
$menu_img = $image->upload_image($_FILES['menu_img']);
if ($menu_img === false) {
show_message($image->error_msg());
}
}
if ($menu_img == '') {
sys_msg('菜單圖片不能為空!', 0, $link);
}
$sql = "insert into " . $GLOBALS['ecs']->table('ecsmart_menu') . "(`menu_name`,`menu_img`,`menu_url`,`sort`) values('{$menu_name}','{$menu_img}','{$menu_url}','{$sort}')";
$num = $GLOBALS['db']->query($sql);
if ($num > 0) {
sys_msg('添加菜單成功!', 0, $link);
} else {
sys_msg('添加菜單失敗!', 0, $link);
}
}
示例9: end
if (!$image->check_img_type($_FILES['avatar']['type'])) {
show_message("圖片格式不正確!");
}
}
}
//會員頭像 by neo
if (!empty($_FILES['avatar']['name'])) {
/* 更新會員頭像之前先刪除舊的頭像 */
$sql = "SELECT avatar " . " FROM " . $GLOBALS['ecs']->table('users') . " WHERE user_id = '{$user_id}'";
$row = $GLOBALS['db']->getRow($sql);
if ($row['avatar'] != '') {
@unlink($row['avatar']);
}
$img_name = $user_id . '.' . end(explode('.', $_FILES['avatar']['name']));
$target = ROOT_PATH . DATA_DIR . '/avatar/';
$original_img = $image->upload_image($_FILES['avatar'], 'avatar', $img_name);
// 原始圖片
$avatar = $image->make_thumb($original_img, 55, 55, $target);
if ($avatar === false) {
show_message("圖片保存出錯!");
}
}
$profile = array('user_id' => $user_id, 'email' => isset($_POST['email']) ? trim($_POST['email']) : '', 'sex' => isset($_POST['sex']) ? intval($_POST['sex']) : 0, 'birthday' => $birthday, 'avatar' => $avatar, 'other' => isset($other) ? $other : array());
if (edit_profile($profile)) {
show_message($_LANG['edit_profile_success'], $_LANG['profile_lnk'], 'user.php?act=profile', 'info');
} else {
if ($user->error == ERR_EMAIL_EXISTS) {
$msg = sprintf($_LANG['email_exist'], $profile['email']);
} else {
$msg = $_LANG['edit_profile_failed'];
}
示例10: elseif
if ($row['original_img'] != '' && is_file('../' . $row['original_img']))
{
/* 先不處理,以防止程序中途出錯停止 */
//$old_original_img = $row['original_img']; //記錄舊圖路徑
}
/* 清除原來商品圖片 */
if ($proc_thumb === false)
{
get_image_path($_REQUEST[goods_id], $row['goods_img'], false, 'goods', true);
get_image_path($_REQUEST[goods_id], $row['goods_thumb'], true, 'goods', true);
}
}
if (empty($is_url_goods_img))
{
$original_img = $image->upload_image($_FILES['goods_img']); // 原始圖片
}
elseif ($_POST['goods_img_url'])
{
if(preg_match('/(.jpg|.png|.gif|.jpeg)$/',$_POST['goods_img_url']) && copy(trim($_POST['goods_img_url']), ROOT_PATH . 'temp/' . basename($_POST['goods_img_url'])))
{
$original_img = 'temp/' . basename($_POST['goods_img_url']);
}
}
if ($original_img === false)
{
sys_msg($image->error_msg(), 1, array(), false);
}
示例11: strpos
$img = $original_img;
// 相冊圖片
$pos = strpos(basename($img), '.');
$newname = dirname($img) . '/' . $image->random_filename() . substr(basename($img), $pos);
if (!copy('../' . $img, '../' . $newname)) {
sys_msg('fail to copy file: ' . realpath('../' . $img), 1, array(), false);
}
$img = $newname;
$gallery_img = $img;
$gallery_thumb = $img;
}
}
// 是否上傳商品縮略圖
if (isset($_FILES['goods_thumb']) && $_FILES['goods_thumb']['tmp_name'] != '' && isset($_FILES['goods_thumb']['tmp_name']) && $_FILES['goods_thumb']['tmp_name'] != 'none') {
// 上傳了,直接使用,原始大小
$goods_thumb = $image->upload_image($_FILES['goods_thumb']);
if ($goods_thumb === false) {
sys_msg($image->error_msg(), 1, array(), false);
}
} else {
// 未上傳,如果自動選擇生成,且上傳了商品圖片,生成所略圖
if ($proc_thumb && isset($_POST['auto_thumb']) && !empty($original_img)) {
// 如果設置縮略圖大小不為0,生成縮略圖
if ($_CFG['thumb_width'] != 0 || $_CFG['thumb_height'] != 0) {
$goods_thumb = $image->make_thumb('../' . $original_img, $GLOBALS['_CFG']['thumb_width'], $GLOBALS['_CFG']['thumb_height']);
if ($goods_thumb === false) {
sys_msg($image->error_msg(), 1, array(), false);
}
} else {
$goods_thumb = $original_img;
}
示例12: array
$smarty->assign('cat_info', array('is_show' => 1));
/* 顯示頁麵 */
$smarty->display('category_flashimg_info.htm');
}
/*------------------------------------------------------ */
//-- 商品分類輪播圖片添加時的處理
/*------------------------------------------------------ */
if ($_REQUEST['act'] == 'insert') {
/* 權限檢查 */
admin_priv('cat_manage');
/* 初始化變量 */
$flashimg['cat_id'] = !empty($_POST['cat_id']) ? intval($_POST['cat_id']) : 0;
$flashimg['sort_order'] = !empty($_POST['sort_order']) ? intval($_POST['sort_order']) : 0;
$flashimg['href_url'] = !empty($_POST['href_url']) ? trim($_POST['href_url']) : '';
/*處理圖片*/
$flashimg['img_url'] = basename($image->upload_image($_FILES['img_url'], 'catflashimg'));
/*處理URL*/
$flashimg['href_url'] = sanitize_url($flashimg['href_url']);
$flashimg['img_title'] = !empty($_POST['img_title']) ? trim($_POST['img_title']) : '';
$flashimg['img_desc'] = !empty($_POST['img_desc']) ? trim($_POST['img_desc']) : '';
/* 入庫的操作 */
if ($db->autoExecute($ecs->table('cat_flashimg'), $flashimg) !== false) {
clear_cache_files();
// 清除緩存
/*添加鏈接*/
$link[0]['text'] = "繼續添加";
$link[0]['href'] = 'category_flashimg.php?act=add&cat_id=' . $cat_id;
$link[1]['text'] = "返回輪播圖片列表";
$link[1]['href'] = 'category_flashimg.php?act=list&cat_id=' . $cat_id;
sys_msg("添加成功", 0, $link);
}
示例13: isset
$link = 'pay.php?act=edit_show_bank&id=' . $id;
if (!$id) {
sys_msg('參數錯誤', 1);
}
if (!empty($_POST)) {
$image = new cls_image($_CFG['bgcolor']);
//實例化圖片處理函數
$bank_name = isset($_POST['bank_name']) ? $_POST['bank_name'] : '';
$bank_code = isset($_POST['bank_code']) ? $_POST['bank_code'] : '';
$bank_image = isset($_FILES['bank_image']) ? $_FILES['bank_image'] : '';
$payment = isset($_POST['payment']) ? $_POST['payment'] : '';
$status = isset($_POST['status']) ? $_POST['status'] : '0';
$bank_img_name = '';
if (isset($bank_image['error']) && $bank_image['error'] == 0) {
if ($image->check_img_type($bank_image['type'])) {
$bank_img_name = $image->upload_image($bank_image, '');
}
if (!$bank_img_name) {
sys_msg('上傳圖片失敗', 1);
}
}
if ($bank_img_name) {
$bank_img = ',bank_img = "' . $bank_img_name . '"';
}
$res = $db->query("update " . $ecs->table('show_bank') . " set bank_name = '{$bank_name}', bank_code = '{$bank_code}',state='{$status}',payment='{$payment}' {$bank_img} where id = {$id}");
if ($res) {
sys_msg('修改成功', 0, array(array('href' => 'pay.php?act=show_bank', 'text' => '返回')));
} else {
sys_msg('修改失敗', 1, array(array('href' => $link, 'text' => '返回')));
}
} else {
示例14: array
$smarty->assign('brand', array('sort_order' => 50, 'is_show' => 1));
$smarty->display('brand_info.htm');
} elseif ($_REQUEST['act'] == 'insert') {
/*檢查品牌名是否重複*/
admin_priv('brand_manage');
$is_show = isset($_REQUEST['is_show']) ? intval($_REQUEST['is_show']) : 0;
$is_only = $exc->is_only('brand_name', $_POST['brand_name']);
if (!$is_only) {
sys_msg(sprintf($_LANG['brandname_exist'], stripslashes($_POST['brand_name'])), 1);
}
/*對描述處理*/
if (!empty($_POST['brand_desc'])) {
$_POST['brand_desc'] = $_POST['brand_desc'];
}
/*處理圖片*/
$img_name = basename($image->upload_image($_FILES['brand_logo'], 'brandlogo'));
/*處理圖片*/
$brand_img = basename($image->upload_image($_FILES['brand_img'], 'brandimg'));
/*處理URL*/
$site_url = sanitize_url($_POST['site_url']);
/*插入數據*/
$sql = "INSERT INTO " . $ecs->table('brand') . "(brand_name, site_url, wap_brand_desc, brand_logo, brand_img,is_show, sort_order) " . "VALUES ('{$_POST['brand_name']}', '{$site_url}', '{$_POST['brand_desc']}', '{$img_name}','{$brand_img}', '{$is_show}', '{$_POST['sort_order']}')";
$db->query($sql);
admin_log($_POST['brand_name'], 'add', 'brand');
/* 清除緩存 */
clear_cache_files();
$link[0]['text'] = $_LANG['continue_add'];
$link[0]['href'] = 'brand.php?act=add';
$link[1]['text'] = $_LANG['back_list'];
$link[1]['href'] = 'brand.php?act=list';
sys_msg($_LANG['brandadd_succed'], 0, $link);
示例15: intval
$cat['is_show'] = !empty($_POST['is_show']) ? intval($_POST['is_show']) : 0;
$cat['grade'] = !empty($_POST['grade']) ? intval($_POST['grade']) : 0;
$cat['filter_attr'] = !empty($_POST['filter_attr']) ? implode(',', array_unique(array_diff($_POST['filter_attr'], array(0)))) : 0;
$cat['cat_recommend'] = !empty($_POST['cat_recommend']) ? $_POST['cat_recommend'] : array();
if (cat_exists($cat['cat_name'], $cat['parent_id'])) {
/* 同級別下不能有重複的分類名稱 */
$link[] = array('text' => $_LANG['go_back'], 'href' => 'javascript:history.back(-1)');
sys_msg($_LANG['catname_exist'], 0, $link);
}
if ($cat['grade'] > 10 || $cat['grade'] < 0) {
/* 價格區間數超過範圍 */
$link[] = array('text' => $_LANG['go_back'], 'href' => 'javascript:history.back(-1)');
sys_msg($_LANG['grade_error'], 0, $link);
}
/* 處理圖片 */
$img_name = basename($image->upload_image($_FILES['cat_ico'], 'cat_ico'));
$cat['cat_ico'] = empty($img_name) ? '' : $img_name;
/* 入庫的操作 */
if ($db->autoExecute($ecs->table('category'), $cat) !== false) {
$cat_id = $db->insert_id();
if ($cat['show_in_nav'] == 1) {
$vieworder = $db->getOne("SELECT max(vieworder) FROM " . $ecs->table('touch_nav') . " WHERE type = 'middle'");
$vieworder += 2;
//顯示在自定義導航欄中
$sql = "INSERT INTO " . $ecs->table('touch_nav') . " (name,ctype,cid,ifshow,vieworder,opennew,url,type)" . " VALUES('" . $cat['cat_name'] . "', 'c', '" . $db->insert_id() . "','1','{$vieworder}','0', '" . build_uri('category', array('cid' => $cat_id), $cat['cat_name']) . "','middle')";
$db->query($sql);
}
insert_cat_recommend($cat['cat_recommend'], $cat_id);
admin_log($_POST['cat_name'], 'add', 'category');
// 記錄管理員操作
clear_cache_files();