Heim  >  Artikel  >  Backend-Entwicklung  >  TP里面的Upload类的疑问

TP里面的Upload类的疑问

WBOY
WBOYOriginal
2016-06-23 13:59:23940Durchsuche

public function add_article(){		if($this->create()){			p($_POST);			p($_FILES);			if(!empty($_FILES['thumb']['name'])){				$upload = new \Think\Upload();				$upload->savePath  		= 		'./upload/article/';				$upload->exts      		=     	array('jpg', 'gif', 'png', 'jpeg');				$upload->maxSize   		= 		3145728;				$info = $upload->upload();				print_r($info);die;				$this->data['thumb']=$file[0]['path'];			}			return $this->add();		}	}

这是我写在我的模型里面的添加文章的方法,调用tp的上传类 能检测到$_FILES数据 可是返回的$info什么都没有 
去看了upload类 里面return empty($info) ? false : $info; 按说就算错误也应该返回false可是什么都没有返回
请问是我使用的不对吗  是最新的3.2的tp框架....先谢过


回复讨论(解决方案)

print_r($upload); 能看到什么?

print_r($upload); 能看到什么?

看到返回给我的信息了,[error:Think\Upload:private]提示我上传根目录不存在,手动创建....

是我忘了配置上传根目录了..这个TP是不自动创建的吗?

可能是他们忽视了吧?毕竟3.2出来还不到一年

可能是他们忽视了吧?毕竟3.2出来还不到一年

我去研究研究他们的类......

谢谢老大!结贴了

Stellungnahme:
Der Inhalt dieses Artikels wird freiwillig von Internetnutzern beigesteuert und das Urheberrecht liegt beim ursprünglichen Autor. Diese Website übernimmt keine entsprechende rechtliche Verantwortung. Wenn Sie Inhalte finden, bei denen der Verdacht eines Plagiats oder einer Rechtsverletzung besteht, wenden Sie sich bitte an admin@php.cn