Ejemplo n.º 1
0
 /**
  * 上传图片
  */
 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 = Uk86Language::uk86_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 Uk86UploadFile();
     $upload->uk86_set('default_dir', ATTACH_GOODS . DS . $_SESSION['store_id'] . DS . $upload->getSysSetPath());
     $upload->uk86_set('max_size', C('image_max_filesize'));
     $upload->uk86_set('thumb_width', GOODS_IMAGES_WIDTH);
     $upload->uk86_set('thumb_height', GOODS_IMAGES_HEIGHT);
     $upload->uk86_set('thumb_ext', GOODS_IMAGES_EXT);
     $upload->uk86_set('fprefix', $_SESSION['store_id']);
     $upload->uk86_set('allow_type', array('gif', 'jpg', 'jpeg', 'png'));
     $result = $upload->uk86_upfile($_POST['id']);
     if (!$result) {
         if (strtoupper(CHARSET) == 'GBK') {
             $upload->error = Uk86Language::uk86_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'] = uk86_cthumb($img_path, 240, $_SESSION['store_id']);
     // 整理为json格式
     $output = json_encode($data);
     echo $output;
     exit;
 }
Ejemplo n.º 2
0
 /**
  * 上传图片
  *
  * @param
  * @return
  */
 public function swfuploadOp()
 {
     /**
      * 读取语言包
      */
     Uk86Language::uk86_read('sns_home');
     $lang = Uk86Language::uk86_getLangContent();
     $member_id = $_SESSION['member_id'];
     $class_id = intval($_POST['category_id']);
     if ($member_id <= 0 && $class_id <= 0) {
         echo json_encode(array('state' => 'false', 'message' => Uk86Language::uk86_get('sns_upload_pic_fail'), 'origin_file_name' => $_FILES["file"]["name"]));
         exit;
     }
     $model = Model();
     // 验证图片数量
     $count = $model->table('sns_albumpic')->where(array('member_id' => $member_id))->count();
     if (C('malbum_max_sum') != 0 && $count >= C('malbum_max_sum')) {
         echo json_encode(array('state' => 'false', 'message' => Uk86Language::uk86_get('sns_upload_img_max_num_error'), 'origin_file_name' => $_FILES["file"]["name"]));
         exit;
     }
     /**
      * 上传图片
      */
     $upload = new Uk86UploadFile();
     $upload_dir = ATTACH_MALBUM . DS . $member_id . DS;
     $upload->uk86_set('default_dir', $upload_dir . $upload->getSysSetPath());
     $thumb_width = '240,1024';
     $thumb_height = '2048,1024';
     $upload->uk86_set('max_size', C('image_max_filesize'));
     $upload->uk86_set('thumb_width', $thumb_width);
     $upload->uk86_set('thumb_height', $thumb_height);
     $upload->uk86_set('fprefix', $member_id);
     $upload->uk86_set('thumb_ext', '_240,_1024');
     $result = $upload->uk86_upfile('file');
     if (!$result) {
         echo json_encode(array('state' => 'false', 'message' => Uk86Language::uk86_get('sns_upload_pic_fail'), 'origin_file_name' => $_FILES["file"]["name"]));
         exit;
     }
     $img_path = $upload->getSysSetPath() . $upload->file_name;
     list($width, $height, $type, $attr) = getimagesize(BASE_UPLOAD_PATH . DS . ATTACH_MALBUM . DS . $member_id . DS . $img_path);
     $image = explode('.', $_FILES["file"]["name"]);
     if (strtoupper(CHARSET) == 'GBK') {
         $image['0'] = Uk86Language::uk86_getGBK($image['0']);
     }
     $insert = array();
     $insert['ap_name'] = $image['0'];
     $insert['ac_id'] = $class_id;
     $insert['ap_cover'] = $img_path;
     $insert['ap_size'] = intval($_FILES['file']['size']);
     $insert['ap_spec'] = $width . 'x' . $height;
     $insert['upload_time'] = time();
     $insert['member_id'] = $member_id;
     $result = $model->table('sns_albumpic')->insert($insert);
     $data = array();
     $data['file_id'] = $result;
     $data['file_name'] = $img_path;
     $data['origin_file_name'] = $_FILES["file"]["name"];
     $data['file_path'] = $img_path;
     $data['file_url'] = uk86_snsThumb($img_path, 240);
     $data['state'] = 'true';
     /**
      * 整理为json格式
      */
     $output = json_encode($data);
     echo $output;
 }
Ejemplo n.º 3
0
 /**
  * 上传图片
  */
 public function image_uploadOp()
 {
     $lang = Uk86Language::uk86_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 Uk86UploadFile();
         $upload_dir = ATTACH_MALBUM . DS . $_SESSION['member_id'] . DS;
         $upload->uk86_set('default_dir', $upload_dir . $upload->getSysSetPath());
         $thumb_width = '240,1024';
         $thumb_height = '2048,1024';
         $upload->uk86_set('max_size', C('image_max_filesize'));
         $upload->uk86_set('thumb_width', $thumb_width);
         $upload->uk86_set('thumb_height', $thumb_height);
         $upload->uk86_set('fprefix', $_SESSION['member_id']);
         $upload->uk86_set('thumb_ext', '_240,_1024');
         $result = $upload->uk86_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');
 }
Ejemplo n.º 4
0
 /**
  * 上传图片
  *
  */
 public function image_uploadOp()
 {
     $store_id = $_SESSION['store_id'];
     if (!empty($_POST['category_id'])) {
         $category_id = intval($_POST['category_id']);
     } else {
         $error = '上传 图片失败';
         if (strtoupper(CHARSET) == 'GBK') {
             $error = Uk86Language::uk86_getUTF8($error);
         }
         $data['state'] = 'false';
         $data['message'] = $error;
         $data['origin_file_name'] = $_FILES["file"]["name"];
         echo json_encode($data);
         exit;
     }
     // 判断图片数量是否超限
     $album_limit = $this->store_grade['sg_album_limit'];
     if ($album_limit > 0) {
         $album_count = Model('album')->getCount(array('store_id' => $store_id));
         if ($album_count >= $album_limit) {
             // 目前并不出该提示,而是提示上传0张图片
             $error = L('store_goods_album_climit');
             if (strtoupper(CHARSET) == 'GBK') {
                 $error = Uk86Language::uk86_getUTF8($error);
             }
             $data['state'] = 'false';
             $data['message'] = $error;
             $data['origin_file_name'] = $_FILES["file"]["name"];
             $data['state'] = 'true';
             echo json_encode($data);
             exit;
         }
     }
     /**
      * 上传图片
      */
     $upload = new Uk86UploadFile();
     $upload->uk86_set('default_dir', ATTACH_GOODS . DS . $store_id . DS . $upload->getSysSetPath());
     $upload->uk86_set('max_size', C('image_max_filesize'));
     $upload->uk86_set('thumb_width', GOODS_IMAGES_WIDTH);
     $upload->uk86_set('thumb_height', GOODS_IMAGES_HEIGHT);
     $upload->uk86_set('thumb_ext', GOODS_IMAGES_EXT);
     $upload->uk86_set('fprefix', $store_id);
     $result = $upload->uk86_upfile('file');
     if ($result) {
         $pic = $upload->getSysSetPath() . $upload->file_name;
         $pic_thumb = $upload->getSysSetPath() . $upload->thumb_image;
     } else {
         // 目前并不出该提示
         $error = $upload->error;
         if (strtoupper(CHARSET) == 'GBK') {
             $error = Uk86Language::uk86_getUTF8($error);
         }
         $data['state'] = 'false';
         $data['message'] = $error;
         $data['origin_file_name'] = $_FILES["file"]["name"];
         echo json_encode($data);
         exit;
     }
     list($width, $height, $type, $attr) = getimagesize(BASE_UPLOAD_PATH . DS . ATTACH_GOODS . DS . $store_id . DS . $pic);
     $image = explode('.', $_FILES["file"]["name"]);
     if (strtoupper(CHARSET) == 'GBK') {
         $image['0'] = Uk86Language::uk86_getGBK($image['0']);
     }
     $insert_array = array();
     $insert_array['apic_name'] = $image['0'];
     $insert_array['apic_tag'] = '';
     $insert_array['aclass_id'] = $category_id;
     $insert_array['apic_cover'] = $pic;
     $insert_array['apic_size'] = intval($_FILES['file']['size']);
     $insert_array['apic_spec'] = $width . 'x' . $height;
     $insert_array['upload_time'] = time();
     $insert_array['store_id'] = $store_id;
     $result = Model('upload_album')->add($insert_array);
     $data = array();
     $data['file_id'] = $result;
     $data['file_name'] = $pic;
     $data['origin_file_name'] = $_FILES["file"]["name"];
     $data['file_path'] = $pic;
     $data['instance'] = $_GET['instance'];
     $data['state'] = 'true';
     /**
      * 整理为json格式
      */
     $output = json_encode($data);
     echo $output;
 }
Ejemplo n.º 5
0
 /**
  * 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'] = Uk86Language::uk86_get('sns_buyershow');
         $default_class['member_id'] = $this->master_id;
         $default_class['ac_des'] = Uk86Language::uk86_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'] = Uk86Language::uk86_get('sns_upload_img_max_num_error');
         $output = json_encode($output);
         echo $output;
         die;
     }
     /**
      * 上传图片
      */
     $upload = new Uk86UploadFile();
     if ($ap_id > 0) {
         $pic_info = $model->table('sns_albumpic')->find($ap_id);
         if (!empty($pic_info)) {
             $upload->uk86_set('file_name', $pic_info['ap_cover']);
         }
         // 原图存在设置图片名称为原图名称
     }
     $upload_dir = ATTACH_MALBUM . DS . $_SESSION['member_id'] . DS;
     $upload->uk86_set('default_dir', $upload_dir . $upload->getSysSetPath());
     $thumb_width = '240,1024';
     $thumb_height = '2048,1024';
     $upload->uk86_set('max_size', C('image_max_filesize'));
     $upload->uk86_set('thumb_width', $thumb_width);
     $upload->uk86_set('thumb_height', $thumb_height);
     $upload->uk86_set('fprefix', $_SESSION['member_id']);
     $upload->uk86_set('thumb_ext', '_240,_1024');
     $result = $upload->uk86_upfile(trim($_POST['id']));
     if (!$result) {
         if (strtoupper(CHARSET) == 'GBK') {
             $upload->error = Uk86Language::uk86_getUTF8($upload->error);
         }
         $output = array();
         $output['error'] = $upload->error;
         $output = json_encode($output);
         echo $output;
         die;
     }
     if ($ap_id <= 0) {
         // 如果原图存在,则不需要在插入数据库
         $img_path = $upload->uk86_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'] = Uk86Language::uk86_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->uk86_getSysSetPath() . $upload->thumb_image;
     $data['file_id'] = $ap_id > 0 ? $pic_info['ap_id'] : $result;
     /**
      * 整理为json格式
      */
     $output = json_encode($data);
     echo $output;
     die;
 }