public function form_post(){
$file=$_FILES['thumb'];
// 实例化上传类
$upload = new \Think\Upload();
// 设置附件上传大小
$upload->maxSize = 2 * 1024 * 1024;
// 设置附件上传根目录
$upload->rootPath = './';
// 设置附件上传(子)目录
$upload->savePath = 'data/upload/portal/';
$info = $upload->uploadOne($file);
$fileinfo=explode('/', $info['savepath']);
$smeta['thumb']='portal/'.$fileinfo['3'].'/'.$info['savename'];
$termid=I('termid');
$article['post_date']=date('Y-m-d H:i:s',time());
$article['post_title']=I('title');
$article['post_excerpt']=I('excerpt');
$article['post_keyword']=I('keyword');
$article['post_content']=I('content');
$article['smeta']=json_encode($smeta);
$article['post_status']=0;
$article['post_author']=1;
$result=M('posts')->add($article);
$result=M('term_relationships')->add(array("term_id"=>intval($termid),"object_id"=>$result));
if($result){
$this->ajaxReturn(array('msg'=>'提交成功'));
}else{
$this->ajaxReturn(array('msg'=>'提交失败'));
}
}
我本地windows测试可以的
但是放到服务器上就不行了(nginx+liunx)