当前位置: 首页>>代码示例>>PHP>>正文


PHP UploadFile::upfile方法代码示例

本文整理汇总了PHP中UploadFile::upfile方法的典型用法代码示例。如果您正苦于以下问题:PHP UploadFile::upfile方法的具体用法?PHP UploadFile::upfile怎么用?PHP UploadFile::upfile使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在UploadFile的用法示例。


在下文中一共展示了UploadFile::upfile方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: save_deliveryOp

 /**
  * 保存申请
  */
 public function save_deliveryOp()
 {
     if (!chksubmit()) {
         showDialog(L('wrong_argument'));
     }
     $insert = array();
     $insert['dlyp_name'] = $_POST['dname'];
     $insert['dlyp_passwd'] = md5($_POST['dpasswd']);
     $insert['dlyp_truename'] = $_POST['dtruename'];
     $insert['dlyp_mobile'] = $_POST['dmobile'];
     $insert['dlyp_telephony'] = $_POST['dtelephony'];
     $insert['dlyp_address_name'] = $_POST['daddressname'];
     $insert['dlyp_area_2'] = $_POST['area_id_2'];
     $insert['dlyp_area_3'] = $_POST['area_id'];
     $insert['dlyp_area_info'] = $_POST['area_info'];
     $insert['dlyp_address'] = $_POST['daddress'];
     $insert['dlyp_idcard'] = $_POST['didcard'];
     $insert['dlyp_addtime'] = TIMESTAMP;
     $insert['dlyp_state'] = 10;
     $upload = new UploadFile();
     $upload->set('default_dir', ATTACH_DELIVERY);
     $result = $upload->upfile('didcardimg');
     if (!$result) {
         showDialog($upload->error);
     }
     $insert['dlyp_idcard_image'] = $upload->file_name;
     $result = Model('delivery_point')->addDeliveryPoint($insert);
     if ($result) {
         showDialog('操作成功,等待管理员审核', 'index.php?act=login', 'succ');
     } else {
         showDialog(L('nc_common_op_fail'));
     }
 }
开发者ID:flying3615,项目名称:chuniang,代码行数:36,代码来源:joinin.php

示例2: store_editOp

 /**
  * 编辑店铺
  */
 public function store_editOp()
 {
     $upload = new UploadFile();
     /**
      * 上传店铺图片
      */
     if (!empty($_FILES['store_banner']['name'])) {
         $upload->set('default_dir', ATTACH_STORE);
         $upload->set('thumb_ext', '');
         $upload->set('file_name', '');
         $upload->set('ifremove', false);
         $result = $upload->upfile('store_banner');
         if ($result) {
             $_POST['store_banner'] = $upload->file_name;
         } else {
             showDialog($upload->error);
         }
     }
     //删除旧店铺图片
     if (!empty($_POST['store_banner']) && !empty($store_info['store_banner'])) {
         @unlink(BASE_UPLOAD_PATH . DS . ATTACH_STORE . DS . $this->store_info['store_banner']);
     }
     /**
      * 更新入库
      */
     $param = array('store_banner' => empty($_POST['store_banner']) ? $this->store_info['store_banner'] : $_POST['store_banner'], 'store_qq' => $_POST['store_qq'], 'store_ww' => $_POST['store_ww'], 'store_phone' => $_POST['store_phone'], 'store_zy' => $_POST['store_zy'], 'store_keywords' => $_POST['seo_keywords'], 'store_description' => $_POST['seo_description']);
     $result = Model('store')->editStore($param, array('store_id' => $this->store_info['store_id']));
     if (!$result) {
         output_error('编辑失败');
     }
     output_data('1');
 }
开发者ID:noikiy,项目名称:meizhan,代码行数:35,代码来源:seller_store.php

示例3: upload_image

function upload_image($file)
{
    require_once '../class/upload.class.php';
    $db_img = new DB();
    if (!empty($file)) {
        $time = time();
        $year_month = date('Ym', $time);
        $day = date('d', $time);
        $uploaddir = SHOPPIC_DIR;
        $pic_array = array();
        foreach ($file as $k => $v) {
            $upload = new UploadFile();
            $upload->set('default_dir', $uploaddir);
            $result = $upload->upfile($k);
            if ($result) {
                $sizeinfo = getimagesize($uploaddir . DS . $upload->file_name);
                $pic_array[] = array($upload->file_name, $v['name'], $v['size'], $sizeinfo[0]);
                unset($sizeinfo);
            }
            unset($upload);
        }
        return $pic_array;
    }
    return array();
}
开发者ID:caidongyun,项目名称:CS,代码行数:25,代码来源:shoplist.add.php

示例4: image_uploadOp

 /**
  * 上传图片
  */
 public function image_uploadOp()
 {
     // 判断图片数量是否超限
     $model_album = Model('album');
     $album_limit = $this->store_grade['sg_album_limit'];
     if ($album_limit > 0) {
         $album_count = $model_album->getCount(array('store_id' => $_SESSION['store_id']));
         if ($album_count >= $album_limit) {
             $error = L('store_goods_album_climit');
             if (strtoupper(CHARSET) == 'GBK') {
                 $error = Language::getUTF8($error);
             }
             exit(json_encode(array('error' => $error)));
         }
     }
     $class_info = $model_album->getOne(array('store_id' => $_SESSION['store_id'], 'is_default' => 1), 'album_class');
     // 上传图片
     $upload = new UploadFile();
     $upload->set('default_dir', ATTACH_GOODS . DS . $_SESSION['store_id'] . DS . $upload->getSysSetPath());
     $upload->set('max_size', C('image_max_filesize'));
     $upload->set('thumb_width', GOODS_IMAGES_WIDTH);
     $upload->set('thumb_height', GOODS_IMAGES_HEIGHT);
     $upload->set('thumb_ext', GOODS_IMAGES_EXT);
     $upload->set('fprefix', $_SESSION['store_id']);
     $upload->set('allow_type', array('gif', 'jpg', 'jpeg', 'png'));
     $result = $upload->upfile($_POST['id']);
     if (!$result) {
         if (strtoupper(CHARSET) == 'GBK') {
             $upload->error = Language::getUTF8($upload->error);
         }
         $output = array();
         $output['error'] = $upload->error;
         $output = json_encode($output);
         exit($output);
     }
     $img_path = $upload->getSysSetPath() . $upload->file_name;
     $thumb_page = $upload->getSysSetPath() . $upload->thumb_image;
     // 取得图像大小
     list($width, $height, $type, $attr) = getimagesize(UPLOAD_SITE_URL . '/' . ATTACH_GOODS . '/' . $_SESSION['store_id'] . DS . $img_path);
     // 存入相册
     $image = explode('.', $_FILES[$_POST['id']]["name"]);
     $insert_array = array();
     $insert_array['apic_name'] = $image['0'];
     $insert_array['apic_tag'] = '';
     $insert_array['aclass_id'] = $class_info['aclass_id'];
     $insert_array['apic_cover'] = $img_path;
     $insert_array['apic_size'] = intval($_FILES[$_POST['id']]['size']);
     $insert_array['apic_spec'] = $width . 'x' . $height;
     $insert_array['upload_time'] = TIMESTAMP;
     $insert_array['store_id'] = $_SESSION['store_id'];
     $model_album->addPic($insert_array);
     $data = array();
     $data['image'] = cthumb($img_path, 240, $_SESSION['store_id']);
     // 整理为json格式
     $output = json_encode($data);
     echo $output;
     exit;
 }
开发者ID:mengtaolin,项目名称:shopping,代码行数:61,代码来源:store_sns.php

示例5: mb_home_editOp

 /**
  * 编辑
  */
 public function mb_home_editOp()
 {
     $model = Model('mb_home');
     if ($_POST['form_submit'] == 'ok') {
         //验证
         $obj_validate = new Validate();
         $obj_validate->validateparam = array(array("input" => $_POST["h_title"], "require" => "true", "message" => L('home_add_null')), array("input" => $_POST["h_desc"], "require" => "true", "message" => L('home_add_null')), array("input" => $_POST["h_keyword"], "require" => "true", "message" => L('home_add_null')), array("input" => $_POST["h_sort"], "require" => "true", 'validator' => 'Number', "message" => L('home_add_sort_int')));
         $error = $obj_validate->validate();
         if ($error != '') {
             showMessage($error);
         } else {
             $home_array = $model->getMbHomeInfoByID(intval($_POST['h_id']));
             //上传图片
             if ($_FILES['h_img']['name'] != '') {
                 $upload = new UploadFile();
                 $upload->set('default_dir', ATTACH_MOBILE . '/home');
                 $result = $upload->upfile('h_img');
                 if ($result) {
                     $_POST['h_img'] = $upload->file_name;
                 } else {
                     showMessage($upload->error);
                 }
             }
             $update_array = array();
             $update_array['h_title'] = trim($_POST['h_title']);
             $update_array['h_desc'] = trim($_POST['h_desc']);
             $update_array['h_keyword'] = trim($_POST['h_keyword']);
             if (!empty($_POST['h_multi_keyword'])) {
                 $update_array['h_multi_keyword'] = $_POST['h_multi_keyword'];
             }
             if ($_POST['h_img']) {
                 $update_array['h_img'] = $_POST['h_img'];
             }
             $update_array['h_sort'] = trim($_POST['h_sort']);
             $condition = array();
             $condition['h_id'] = intval($_POST['h_id']);
             $result = $model->editMbHome($update_array, $condition);
             if ($result) {
                 //除图片
                 if (!empty($_POST['h_img']) && !empty($home_array['h_img'])) {
                     @unlink(BASE_ROOT_PATH . DS . DIR_UPLOAD . DS . ATTACH_MOBILE . '/home' . DS . $home_array['h_img']);
                 }
                 showMessage(L('home_edit_succ'), 'index.php?act=mb_home&op=mb_home_list');
             } else {
                 showMessage(L('home_edit_fail'));
             }
         }
     }
     $home_array = $model->getMbHomeInfoByID(intval($_GET['h_id']));
     if (empty($home_array)) {
         showMessage(L('wrong_argument'));
     }
     Tpl::output('home_array', $home_array);
     Tpl::showpage('mb_home.edit');
 }
开发者ID:flying3615,项目名称:chuniang,代码行数:58,代码来源:mb_home.php

示例6: indexOp

	/**
	 * 店铺打印设置
	 */
	public function indexOp(){
		$model = Model();
		$store_info = $model->table('store')->where(array('store_id'=>$_SESSION['store_id']))->find();
		if(empty($store_info)){
			showDialog(Language::get('store_storeinfo_error'),'index.php?act=store_printsetup','error');
		}
		if(chksubmit()){
			$obj_validate = new Validate();
			$obj_validate->validateparam = array(
				array("input"=>$_POST['store_printdesc'], "require"=>"true","validator"=>"Length","min"=>1,"max"=>200,"message"=>Language::get('store_printsetup_desc_error'))
			);
			$error = $obj_validate->validate();
			if ($error != ''){
				showDialog($error);
			}
			$update_arr = array();
			//上传认证文件
			if($_FILES['store_stamp']['name'] != '') {
				$upload = new UploadFile();
				$upload->set('default_dir',ATTACH_STORE);
				if($_FILES['store_stamp']['name'] != '') {
					$result = $upload->upfile('store_stamp');
					if ($result){
						$update_arr['store_stamp'] = $upload->file_name;
						//删除旧认证图片
						if (!empty($store_info['store_stamp'])){
							@unlink(BASE_UPLOAD_PATH.DS.ATTACH_STORE.DS.$store_info['store_stamp']);
						}
					}
				}
			}
			$update_arr['store_printdesc'] = $_POST['store_printdesc'];
			$rs = $model->table('store')->where(array('store_id'=>$_SESSION['store_id']))->update($update_arr);
			if ($rs){
				showDialog(Language::get('nc_common_save_succ'),'index.php?act=store_printsetup','succ');
			}else {
				showDialog(Language::get('nc_common_save_fail'),'index.php?act=store_printsetup','error');
			}
		}else{
			Tpl::output('store_info',$store_info);
			self::profile_menu('store_printsetup');
			Tpl::showpage('store_printsetup');
		}
	}
开发者ID:noikiy,项目名称:ejia,代码行数:47,代码来源:store_printsetup.php

示例7: pic_uploadOp

 /**
  * 图片上传
  *
  */
 public function pic_uploadOp()
 {
     if (chksubmit()) {
         //上传图片
         $upload = new UploadFile();
         $upload->set('thumb_width', 500);
         $upload->set('thumb_height', 499);
         $upload->set('thumb_ext', '_small');
         $upload->set('max_size', C('image_max_filesize') ? C('image_max_filesize') : 1024);
         $upload->set('ifremove', true);
         $upload->set('default_dir', $_GET['uploadpath']);
         if (!empty($_FILES['c_img']['tmp_name'])) {
             $result = $upload->upfile('c_img');
             if ($result) {
                 exit(json_encode(array('status' => 1, 'url' => UPLOAD_SITE_URL . '/' . $_GET['uploadpath'] . '/' . $upload->thumb_image)));
             } else {
                 exit(json_encode(array('status' => 0, 'msg' => $upload->error)));
             }
         }
     }
 }
开发者ID:dotku,项目名称:shopnc_cnnewyork,代码行数:25,代码来源:cut.php

示例8: cms_manage_saveOp

 /**
  * cms设置保存
  */
 public function cms_manage_saveOp()
 {
     $model_setting = Model('setting');
     $update_array = array();
     $update_array['cms_isuse'] = intval($_POST['cms_isuse']);
     if (!empty($_FILES['cms_logo']['name'])) {
         $upload = new UploadFile();
         $upload->set('default_dir', ATTACH_CMS);
         $result = $upload->upfile('cms_logo');
         if (!$result) {
             showMessage($upload->error);
         }
         $update_array['cms_logo'] = $upload->file_name;
         $old_image = BASE_UPLOAD_PATH . DS . ATTACH_CMS . DS . C('microshop_logo');
         if (is_file($old_image)) {
             unlink($old_image);
         }
     }
     $update_array['cms_submit_verify_flag'] = intval($_POST['cms_submit_verify_flag']);
     $update_array['cms_comment_flag'] = intval($_POST['cms_comment_flag']);
     $update_array['cms_attitude_flag'] = intval($_POST['cms_attitude_flag']);
     $update_array['taobao_api_isuse'] = intval($_POST['taobao_api_isuse']);
     $update_array['taobao_app_key'] = $_POST['taobao_app_key'];
     $update_array['taobao_secret_key'] = $_POST['taobao_secret_key'];
     $update_array['cms_seo_title'] = $_POST['cms_seo_title'];
     $update_array['cms_seo_keywords'] = $_POST['cms_seo_keywords'];
     $update_array['cms_seo_description'] = $_POST['cms_seo_description'];
     $result = $model_setting->updateSetting($update_array);
     if ($result === true) {
         $this->log(Language::get('cms_log_manage_save'), 0);
         showMessage(Language::get('nc_common_save_succ'));
     } else {
         $this->log(Language::get('cms_log_manage_save'), 0);
         showMessage(Language::get('nc_common_save_fail'));
     }
 }
开发者ID:flying3615,项目名称:chuniang,代码行数:39,代码来源:cms_manage.php

示例9: image_uploadOp

 /**
  * 上传图片
  */
 public function image_uploadOp()
 {
     $lang = Language::getLangContent();
     if ($_GET['upload_type'] == 'uploadedfile') {
         if ($_POST['file_id'] != '') {
             $model_store_goods = Model('flea');
             $drop_stata = $model_store_goods->dropImageGoods(array('upload_id' => intval($_POST['file_id'])));
         }
         /**
          * 实例化json模型
          */
         /**
          * 上传图片
          */
         $upload = new UploadFile();
         $upload_dir = ATTACH_MALBUM . DS . $_SESSION['member_id'] . DS;
         $upload->set('default_dir', $upload_dir . $upload->getSysSetPath());
         $thumb_width = '240,1024';
         $thumb_height = '2048,1024';
         $upload->set('max_size', C('image_max_filesize'));
         $upload->set('thumb_width', $thumb_width);
         $upload->set('thumb_height', $thumb_height);
         $upload->set('fprefix', $_SESSION['member_id']);
         $upload->set('thumb_ext', '_240,_1024');
         $result = $upload->upfile('file');
         if ($result) {
             $_POST['pic'] = $upload->getSysSetPath() . $upload->file_name;
             $_POST['pic_thumb'] = $upload->getSysSetPath() . $upload->thumb_image;
         } else {
             //				echo json_encode(array('state'=>'false','message'=>$lang['iswfupload_upload_pic_fail']));
             echo "<script type='text/javascript'>alert('" . $upload->error . "');history.back();</script>";
             exit;
         }
         $img_path = $_POST['pic'];
         /**
          * 取得图像大小
          */
         list($width, $height, $type, $attr) = getimagesize(BASE_UPLOAD_PATH . DS . ATTACH_MALBUM . DS . $_SESSION['member_id'] . DS . $img_path);
         /**
          * 图片数据入库
          */
         $model_upload = Model('flea_upload');
         $insert_array = array();
         $image_type = array('goods_image' => 12, 'desc_image' => 13);
         //debug
         $insert_array['file_name'] = $_POST['pic'];
         $insert_array['file_thumb'] = $_POST['pic_thumb'];
         $insert_array['file_size'] = intval($_FILES['file']['size']);
         $insert_array['upload_time'] = time();
         $insert_array['item_id'] = intval($_POST['item_id']);
         $insert_array['store_id'] = $_SESSION['member_id'];
         $insert_array['upload_type'] = $image_type['goods_image'];
         $result2 = $model_upload->add($insert_array);
         $data = array();
         $data['file_id'] = $result2;
         $data['file_name'] = $_POST['pic_thumb'];
         $data['file_path'] = $_POST['pic_thumb'];
         $data['instance'] = 'goods_image';
         $data['id'] = $_POST['id'];
         /**
          * 整理为json格式
          */
         $output = json_encode($data);
         echo "<script type='text/javascript'>window.parent.add_uploadedfile('" . $output . "');</script>";
     }
     Tpl::showpage('flea_upload_image', 'null_layout');
 }
开发者ID:uwitec,项目名称:xbshop,代码行数:70,代码来源:member_flea.php

示例10: reopen_uploadOp

 public function reopen_uploadOp()
 {
     if (!chksubmit()) {
         exit;
     }
     $upload = new UploadFile();
     $uploaddir = ATTACH_PATH . DS . 'store_joinin' . DS;
     $upload->set('default_dir', $uploaddir);
     $upload->set('allow_type', array('jpg', 'jpeg', 'gif', 'png'));
     if (!empty($_FILES['re_pay_cert']['tmp_name'])) {
         $result = $upload->upfile('re_pay_cert');
         if ($result) {
             $pic_name = $upload->file_name;
         }
     }
     $data = array();
     $data['re_pay_cert'] = $pic_name;
     $data['re_pay_cert_explain'] = $_POST['re_pay_cert_explain'];
     $data['re_state'] = 1;
     $model_store_reopen = Model('store_reopen');
     $update = $model_store_reopen->editStoreReopen($data, array('re_id' => $_POST['re_id'], 're_state' => 0));
     if ($update) {
         showDialog('上传成功,请等待系统审核', 'reload', 'succ');
     } else {
         showDialog(Language::get('nc_common_del_fail'));
     }
 }
开发者ID:xuxuecheng,项目名称:shopnc,代码行数:27,代码来源:store_info.php

示例11: article_image_uploadOp

 /**
  * 文章图片上传
  */
 public function article_image_uploadOp()
 {
     $data = array();
     $data['status'] = 'success';
     if (!empty($this->publisher_name)) {
         if (!empty($_FILES['article_image_upload']['name'])) {
             $upload = new UploadFile();
             $upload->set('default_dir', ATTACH_CMS . DS . 'article' . DS . $this->attachment_path);
             $upload->set('thumb_width', '1024,240');
             $upload->set('thumb_height', '50000,5000');
             $upload->set('thumb_ext', '_max,_list');
             $result = $upload->upfile('article_image_upload');
             if (!$result) {
                 $data['status'] = 'fail';
                 $data['error'] = '图片上传失败';
             }
             $data['file_name'] = $upload->file_name;
             $data['origin_file_name'] = $_FILES['article_image_upload']['name'];
             $data['file_url'] = getCMSArticleImageUrl($this->attachment_path, $upload->file_name, 'max');
             $data['file_path'] = $this->attachment_path;
         }
     } else {
         $data['status'] = 'fail';
         $data['error'] = Language::get('no_login');
     }
     self::echo_json($data);
 }
开发者ID:noikiy,项目名称:cunkou,代码行数:30,代码来源:publish.php

示例12: image_uploadOp

 /**
  * ajax图片上传
  */
 public function image_uploadOp()
 {
     $ap_id = intval($_POST['apid']);
     /**
      * 相册
      */
     $model = Model();
     $default_class = $model->table('sns_albumclass')->where(array('member_id' => $_SESSION['member_id'], 'is_default' => 1))->find();
     if (empty($default_class)) {
         // 验证时候存在买家秀相册,不存在添加。
         $default_class = array();
         $default_class['ac_name'] = Language::get('sns_buyershow');
         $default_class['member_id'] = $this->master_id;
         $default_class['ac_des'] = Language::get('sns_buyershow_album_des');
         $default_class['ac_sort'] = '255';
         $default_class['is_default'] = 1;
         $default_class['upload_time'] = time();
         $default_class['ac_id'] = $model->table('sns_albumclass')->insert($default_class);
     }
     // 验证图片数量
     $count = $model->table('sns_albumpic')->where(array('member_id' => $_SESSION['member_id']))->count();
     if (C('malbum_max_sum') != 0 && $count >= C('malbum_max_sum')) {
         $output = array();
         $output['error'] = Language::get('sns_upload_img_max_num_error');
         $output = json_encode($output);
         echo $output;
         die;
     }
     /**
      * 上传图片
      */
     $upload = new UploadFile();
     if ($ap_id > 0) {
         $pic_info = $model->table('sns_albumpic')->find($ap_id);
         if (!empty($pic_info)) {
             $upload->set('file_name', $pic_info['ap_cover']);
         }
         // 原图存在设置图片名称为原图名称
     }
     $upload_dir = ATTACH_MALBUM . DS . $_SESSION['member_id'] . DS;
     $upload->set('default_dir', $upload_dir . $upload->getSysSetPath());
     $thumb_width = '240,1024';
     $thumb_height = '2048,1024';
     $upload->set('max_size', C('image_max_filesize'));
     $upload->set('thumb_width', $thumb_width);
     $upload->set('thumb_height', $thumb_height);
     $upload->set('fprefix', $_SESSION['member_id']);
     $upload->set('thumb_ext', '_240,_1024');
     $result = $upload->upfile(trim($_POST['id']));
     if (!$result) {
         if (strtoupper(CHARSET) == 'GBK') {
             $upload->error = Language::getUTF8($upload->error);
         }
         $output = array();
         $output['error'] = $upload->error;
         $output = json_encode($output);
         echo $output;
         die;
     }
     if ($ap_id <= 0) {
         // 如果原图存在,则不需要在插入数据库
         $img_path = $upload->getSysSetPath() . $upload->file_name;
         list($width, $height, $type, $attr) = getimagesize(BASE_UPLOAD_PATH . DS . ATTACH_MALBUM . DS . $_SESSION['member_id'] . DS . $img_path);
         $image = explode('.', $_FILES[trim($_POST['id'])]["name"]);
         if (strtoupper(CHARSET) == 'GBK') {
             $image['0'] = Language::getGBK($image['0']);
         }
         $insert = array();
         $insert['ap_name'] = $image['0'];
         $insert['ac_id'] = $default_class['ac_id'];
         $insert['ap_cover'] = $img_path;
         $insert['ap_size'] = intval($_FILES[trim($_POST['id'])]['size']);
         $insert['ap_spec'] = $width . 'x' . $height;
         $insert['upload_time'] = time();
         $insert['member_id'] = $_SESSION['member_id'];
         $insert['ap_type'] = 1;
         $insert['item_id'] = intval($_POST['sid']);
         $result = $model->table('sns_albumpic')->insert($insert);
     }
     $data = array();
     $data['file_name'] = $ap_id > 0 ? $pic_info['ap_cover'] : $upload->getSysSetPath() . $upload->thumb_image;
     $data['file_id'] = $ap_id > 0 ? $pic_info['ap_id'] : $result;
     /**
      * 整理为json格式
      */
     $output = json_encode($data);
     echo $output;
     die;
 }
开发者ID:mengtaolin,项目名称:shopping,代码行数:92,代码来源:member_snshome.php

示例13: goods_class_editOp

 /**
  * 编辑
  */
 public function goods_class_editOp()
 {
     $lang = Language::getLangContent();
     $model_class = Model('goods_class');
     if (chksubmit()) {
         $obj_validate = new Validate();
         $obj_validate->validateparam = array(array("input" => $_POST["gc_name"], "require" => "true", "message" => $lang['goods_class_add_name_null']), array("input" => $_POST["commis_rate"], "require" => "true", 'validator' => 'range', 'max' => 100, 'min' => 0, "message" => $lang['goods_class_add_commis_rate_error']), array("input" => $_POST["gc_sort"], "require" => "true", 'validator' => 'Number', "message" => $lang['goods_class_add_sort_int']));
         $error = $obj_validate->validate();
         if ($error != '') {
             showMessage($error);
         }
         // 更新分类信息
         $where = array('gc_id' => intval($_POST['gc_id']));
         $update_array = array();
         $update_array['gc_name'] = $_POST['gc_name'];
         $update_array['type_id'] = intval($_POST['t_id']);
         $update_array['type_name'] = trim($_POST['t_name']);
         $update_array['commis_rate'] = intval($_POST['commis_rate']);
         $update_array['gc_sort'] = intval($_POST['gc_sort']);
         $update_array['gc_virtual'] = intval($_POST['gc_virtual']);
         $result = $model_class->editGoodsClass($update_array, $where);
         if (!$result) {
             $this->log(L('nc_edit,goods_class_index_class') . '[' . $_POST['gc_name'] . ']', 0);
             showMessage($lang['goods_class_batch_edit_fail']);
         }
         if (!empty($_FILES['pic']['name'])) {
             //上传图片
             $upload = new UploadFile();
             $upload->set('default_dir', ATTACH_COMMON);
             $upload->set('file_name', 'category-pic-' . intval($_POST['gc_id']) . '.jpg');
             $upload->upfile('pic');
         }
         // 检测是否需要关联自己操作,统一查询子分类
         if ($_POST['t_commis_rate'] == '1' || $_POST['t_associated'] == '1' || $_POST['t_gc_virtual'] == '1') {
             $gc_id_list = $model_class->getChildClass($_POST['gc_id']);
             $gc_ids = array();
             if (is_array($gc_id_list) && !empty($gc_id_list)) {
                 foreach ($gc_id_list as $val) {
                     $gc_ids[] = $val['gc_id'];
                 }
             }
         }
         // 更新该分类下子分类的所有分佣比例
         if ($_POST['t_commis_rate'] == '1' && !empty($gc_ids)) {
             $model_class->editGoodsClass(array('commis_rate' => $update_array['commis_rate']), array('gc_id' => array('in', $gc_ids)));
         }
         // 更新该分类下子分类的所有类型
         if ($_POST['t_associated'] == '1' && !empty($gc_ids)) {
             $where = array();
             $where['gc_id'] = array('in', $gc_ids);
             $update = array();
             $update['type_id'] = intval($_POST['t_id']);
             $update['type_name'] = trim($_POST['t_name']);
             $model_class->editGoodsClass($update, $where);
         }
         // 虚拟商品
         if ($_POST['t_gc_virtual'] == '1' && !empty($gc_ids)) {
             $model_class->editGoodsClass(array('gc_virtual' => $update_array['gc_virtual']), array('gc_id' => array('in', $gc_ids)));
         }
         $url = array(array('url' => 'index.php?act=goods_class&op=goods_class_edit&gc_id=' . intval($_POST['gc_id']), 'msg' => $lang['goods_class_batch_edit_again']), array('url' => 'index.php?act=goods_class&op=goods_class', 'msg' => $lang['goods_class_add_back_to_list']));
         $this->log(L('nc_edit,goods_class_index_class') . '[' . $_POST['gc_name'] . ']', 1);
         showMessage($lang['goods_class_batch_edit_ok'], $url, 'html', 'succ', 1, 5000);
     }
     $class_array = $model_class->getGoodsClassInfoById(intval($_GET['gc_id']));
     if (empty($class_array)) {
         showMessage($lang['goods_class_batch_edit_paramerror']);
     }
     //类型列表
     $model_type = Model('type');
     $type_list = $model_type->typeList(array('order' => 'type_sort asc'), '', 'type_id,type_name,class_id,class_name');
     $t_list = array();
     if (is_array($type_list) && !empty($type_list)) {
         foreach ($type_list as $k => $val) {
             $t_list[$val['class_id']]['type'][$k] = $val;
             $t_list[$val['class_id']]['name'] = $val['class_name'] == '' ? L('nc_default') : $val['class_name'];
         }
     }
     ksort($t_list);
     //父类列表,只取到第二级
     $parent_list = $model_class->getTreeClassList(2);
     if (is_array($parent_list)) {
         foreach ($parent_list as $k => $v) {
             $parent_list[$k]['gc_name'] = str_repeat("&nbsp;", $v['deep'] * 2) . $v['gc_name'];
         }
     }
     Tpl::output('parent_list', $parent_list);
     // 一级分类列表
     $gc_list = Model('goods_class')->getGoodsClassListByParentId(0);
     Tpl::output('gc_list', $gc_list);
     $pic_name = BASE_UPLOAD_PATH . '/' . ATTACH_COMMON . '/category-pic-' . $class_array['gc_id'] . '.jpg';
     if (file_exists($pic_name)) {
         $class_array['pic'] = UPLOAD_SITE_URL . '/' . ATTACH_COMMON . '/category-pic-' . $class_array['gc_id'] . '.jpg';
     }
     Tpl::output('type_list', $t_list);
     Tpl::output('class_array', $class_array);
     $this->links[] = array('url' => 'act=goods_class&op=goods_class_edit', 'lang' => 'nc_edit');
     Tpl::output('top_link', $this->sublink($this->links, 'goods_class_edit'));
//.........这里部分代码省略.........
开发者ID:sunxguo,项目名称:qyg,代码行数:101,代码来源:goods_class.php

示例14: brand_editOp

 /**
  * 品牌编辑
  */
 public function brand_editOp()
 {
     $lang = Language::getLangContent();
     $model_brand = Model('brand');
     if ($_POST['form_submit'] == 'ok') {
         /**
          * 验证
          */
         $obj_validate = new Validate();
         $obj_validate->validateparam = array(array("input" => $_POST["brand_name"], "require" => "true", "message" => $lang['brand_add_name_null']), array("input" => $_POST["brand_sort"], "require" => "true", 'validator' => 'Number', "message" => $lang['brand_add_sort_int']));
         $error = $obj_validate->validate();
         if ($error != '') {
             showMessage($error);
         } else {
             /**
              * 上传图片
              */
             $upload = new UploadFile();
             $upload->set('default_dir', ATTACH_BRAND);
             /**
              * 默认商品图片
              */
             if (!empty($_FILES['brand_pic']['name'])) {
                 $result = $upload->upfile('brand_pic');
                 if ($result) {
                     $_POST['brand_pic'] = $upload->file_name;
                 } else {
                     showMessage($upload->error, '', '', 'error');
                 }
             }
             $update_array = array();
             $update_array['brand_id'] = intval($_POST['brand_id']);
             $update_array['brand_name'] = trim($_POST['brand_name']);
             $update_array['brand_class'] = trim($_POST['brand_class']);
             if (!empty($_POST['brand_pic'])) {
                 $update_array['brand_pic'] = $_POST['brand_pic'];
             }
             $update_array['brand_recommend'] = intval($_POST['brand_recommend']);
             $update_array['brand_sort'] = intval($_POST['brand_sort']);
             $result = $model_brand->update($update_array);
             if ($result) {
                 /**
                  * 删除老图片
                  */
                 if (!empty($_POST['brand_pic']) && !empty($_POST['old_brand_pic'])) {
                     @unlink(BasePath . DS . ATTACH_BRAND . DS . $_POST['old_brand_pic']);
                 }
                 $url = array(array('url' => 'index.php?act=brand&op=brand_edit&brand_id=' . intval($_POST['brand_id']), 'msg' => $lang['brand_edit_again']), array('url' => 'index.php?act=brand&op=brand', 'msg' => $lang['brand_add_back_to_list']));
                 showMessage($lang['brand_edit_succ'], $url);
             } else {
                 showMessage($lang['brand_edit_fail']);
             }
         }
     }
     $brand_array = $model_brand->getOneBrand(intval($_GET['brand_id']));
     if (empty($brand_array)) {
         showMessage($lang['wrong_argument']);
     }
     Tpl::output('brand_array', $brand_array);
     Tpl::showpage('brand.edit');
 }
开发者ID:noikiy,项目名称:ecmall,代码行数:64,代码来源:brand.php

示例15: upload_image

 private function upload_image($file)
 {
     $pic_name = '';
     $upload = new UploadFile();
     $uploaddir = ATTACH_PATH . DS . 'store_joinin' . DS;
     $upload->set('default_dir', $uploaddir);
     $upload->set('allow_type', array('jpg', 'jpeg', 'gif', 'png'));
     if (!empty($_FILES[$file]['name'])) {
         $result = $upload->upfile($file);
         if ($result) {
             $pic_name = $upload->file_name;
             $upload->file_name = '';
         }
     }
     return $pic_name;
 }
开发者ID:dotku,项目名称:shopnc_cnnewyork,代码行数:16,代码来源:store_joinin.php


注:本文中的UploadFile::upfile方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。