文件未上载到cakephp中的文件夹(无插件)

文件未上载到cakephp中的文件夹(无插件),cakephp,Cakephp,我正在将文件上传到CakePHP中的一个文件夹中。我已经编写了以下代码。文件名已正确插入数据库,但文件未上载 function addtickets(){ $this->data['Ticket']['attachment']=date('YmdHis').$this->data['Ticket']['attachment']['name']; if ($this->Ticket->save($this->data)){

我正在将文件上传到CakePHP中的一个文件夹中。我已经编写了以下代码。文件名已正确插入数据库,但文件未上载

function addtickets(){
$this->data['Ticket']['attachment']=date('YmdHis').$this->data['Ticket']['attachment']['name'];
            if ($this->Ticket->save($this->data)){
                $target_path = "bug/app/tmp/uploads/";
                $target_path = $target_path . basename( $_FILES['Ticket']['attachment']['name']); 
                if(move_uploaded_file($_FILES['Ticket']['attachment']['tmp_name'], $target_path)) {
                    echo "The file ".  basename( $_FILES['Ticket']['attachment']['name']). 
                    " has been uploaded";
                    } else{
                    echo "There was an error uploading the file, please try again!";
                }
         $this->Session->setFlash('Ticket created');
} else {
                $this->Session->setFlash('Cannot create a ticket');
            }
    }
我在位置
bug/app/tmp/uploads
上有uploads文件夹,它是可写的

但在点击提交按钮后,所有插入到数据库中的值,但文件并没有上传

请帮忙 谢谢你试试这个

$new_file_location = APP.'tmp'.DS.'uploads'.DS.$this->data['Ticket']["attachment"]['name'];

move_uploaded_file($this->data['Ticket']["attachment"]['tmp_name'], $new_file_location);