where(array('ap_id' => $v, 'member_id' => session('member_id')))->find(); if (empty($ap_info)) continue; @unlink(BASE_UPLOAD_PATH . DIRECTORY_SEPARATOR . ATTACH_MALBUM . DIRECTORY_SEPARATOR . session('member_id') . DIRECTORY_SEPARATOR . $ap_info['ap_cover']); $res = Db::name('snsalbumpic')->delete($ap_info['ap_id']); } if ($res) { ds_json_encode(10000, lang('ds_common_del_succ')); } } /** * 上传图片 * * @param * @return */ public function swfupload() { $member_id = session('member_id'); $class_id = intval(input('param.category_id')); if ($member_id <= 0 && $class_id <= 0) { echo json_encode(array('state' => 'false', 'message' => lang('sns_upload_pic_fail'), 'origin_file_name' => $_FILES["file"]["name"])); exit; } /** * 上传图片 */ //上传文件保存路径 if (!empty($_FILES['file']['name'])) { //设置特殊图片名称 $file_name = $member_id . '_' . date('YmdHis') . rand(10000, 99999) . '.png'; $res = ds_upload_pic(ATTACH_MALBUM . DIRECTORY_SEPARATOR . $member_id, 'file', $file_name); if ($res['code']) { $file_name = $res['data']['file_name']; $img_path = $file_name; } else { // 目前并不出该提示 $error = $res['msg']; $data['state'] = 'false'; $data['message'] = $error; $data['origin_file_name'] = $_FILES['file']['name']; echo json_encode($data); exit; } } else { //未上传图片不做后面处理 exit; } list($width, $height, $type, $attr) = getimagesize(ds_get_pic(ATTACH_MALBUM . DIRECTORY_SEPARATOR . $member_id, $img_path)); $insert = array(); $insert['ap_name'] = $img_path; $insert['ac_id'] = $class_id; $insert['ap_cover'] = $img_path; $insert['ap_size'] = intval($_FILES['file']['size']); $insert['ap_spec'] = $width . 'x' . $height; $insert['ap_uploadtime'] = TIMESTAMP; $insert['member_id'] = $member_id; $result = Db::name('snsalbumpic')->insertGetId($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'] = sns_thumb($img_path, 240); $data['state'] = 'true'; /** * 整理为json格式 */ $output = json_encode($data); echo $output; } } ?>