fonction publique ajouter(){
$cours=D('cours');
si (IS_POST){
$date['nom']=I('nom');
$date['descs']=I('descs');
$date['content']=I('content');
$date['cateid']=I('cateid');
$date['update_date']=Date("A-m-d h:i:s");
$upload->maxSize=5*1024*1024 ;
$upload->exts=array('jpg','gif','png','jpeg');
$upload->rootPath='./Public/';
$upload->savePath='téléchargements/';
$upload->autoSub = faux ;
si ($_FILES['pic']['name']) {
$info=$upload->upload();
si ($info) {
$this->error($upload->getError() );
}autre{
$_POST["pic"]=$info["pic"]["savePath"].$info["pic"]["saveName"];
}
}autre{
$_POST["pic"]="uploads/empty.jpg";
}
si ($cours->créer($data)){
si($cours->ajouter()){
$this->success('添加课程成功!',U('lst'));
}autre {
$this->error('添加课程失败!');
}
}autre {
$this->error($courses->getError());
}
retour;
}
$cateres=D('cate')->select();
$this->assign('cateres',$cateres);
$this->affichage();
}
后台显示图裂开,数据库中图片的路径是上传前图片的路径,如名称.jpg,Public中没有文件上传上去