<?php
namespace Home\Controller;
use Think\Controller;
class IndexController extends Controller {
public function index(){
R("Login/index");
$goods = M('goods')->select();
$this->assign('goods',$goods);
$this->display();
}
public function me(){
R("Login/index");
$user = M("user"); // 实例化User对象
$where = array('userid'=>session('userid'));
$result = $user->where($where)->find();
$this->assign('id',$result['id']);
$this->assign('name',$result['nickname']);
$this->assign('url',$result['headimgurl']);
$this->display();
}
public function fabu(){
// R("Login/index");
$this->display();
}
function addgoods(){
// R("Login/index");
$this->upload();die;
// dump($_FILES);die;
$data['name'] = I('name');
$data['phone'] = I('phone');
$data['address'] = I('address');
$data['type'] = I('type');
$data['cate'] = I('cate');
$data['textarea'] = I('textarea');
$data['userid'] = S('user_id');
$data['create_time'] = date("y-m-d",time());
if(empty(I('name'))||empty(I('phone'))||empty(I('type'))||empty(I('address')||empty(I('cate'))||empty(I('textarea')))){
redirect('fabu.html');
}else{
$goods = M("goods"); // 实例化User对象
$where = array('userid'=>S('user_id'));
@header("Content-Type:text/html;charset=utf-8");
if($goods->where($where)->count()<1){
$result=$goods->add($data);
if($result){
$this->show_msg('添加数据成功!','index.html');
}
}else{
if($goods->where(array('userid'=>S('user_id'),'type'=>'1'))){
$result=$goods->add($data);
if($result){
$this->show_msg('添加数据成功!','index.html');
}
}else{
$this->show_msg('普通用户只能发布一条信息,如果想再发,请联系客服升级成VIP','ewm.html');
}
}
}
}
public function mypublish(){
$goods = M("goods"); // 实例化User对象
$where = array('userid'=>S('user_id'));
$result = $goods->where($where)->select();
$this->assign('goods',$result);
$this->display();
}
public function delmygoods(){
$goods = M("goods"); // 实例化User对象
$where = array('userid'=>S('user_id'),'id'=>I('goodsid'));
$result = $goods->where($where)->delete();
$this->show_msg('删除成功','../../me.html');
}
public function ewm(){
$this->display();
}
public function upload(){
$upload = new \Think\Upload();// 实例化上传类
$upload->maxSize = 3145728 ;// 设置附件上传大小
$upload->exts = array('jpg', 'gif', 'png', 'jpeg');// 设置附件上传类型
$upload->rootPath = './upload/'; // 设置附件上传根目录
$upload->savePath = ''; // 设置附件上传(子)目录
// 上传文件
$info = $upload->upload();
if(!$info) {// 上传错误提示错误信息
$this->error($upload->getError());
}else{// 上传成功 获取上传文件信息
foreach($info as $file){
echo $file['savepath'].$file['savename'].",";
}
}
}
public function show_msg($msg, $url){
@header("Content-Type:text/html;charset=utf-8");
echo '<script type="text/javascript">';
echo 'alert("'.$msg.'");';
if(!empty($url)){
echo 'location.href = "'.$url.'"';
}else{
echo 'history.go(-1);';
}
echo '</script>';
exit;
}
}
没有合适的资源?快使用搜索试试~ 我知道了~
thinkphp3.2多图上传预览+模板提交到后台
所需积分/C币: 50 浏览量·274 ZIP 6KB 2018-11-06 00:09:38 上传
身份认证 购VIP最低享 7 折!

终于不要ajax 就可以上传预览图片了,不占资源,自由提交才上传文件
资源推荐
资源详情
资源评论











收起资源包目录




共 3 条
- 1
资源评论

神龙见首不见尾
- 粉丝: 1
- 资源: 3

上传资源 快速赚钱
我的内容管理 展开
我的资源 快来上传第一个资源
我的收益
登录查看自己的收益我的积分 登录查看自己的积分
我的C币 登录后查看C币余额
我的收藏
已下载
下载帮助

内容简介:Desktop.zip index.css fabu.html IndexController.class.php
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈



安全验证
文档复制为VIP权益,开通VIP直接复制
