文件没有上传,没有移动cakePHP

时间:2013-09-06 09:55:04

标签: php cakephp file-upload

在我的cakePHP项目中,在上传文件中,我面临以下问题:

pr($resume['tmp_name']);正在返回文件路径,但文件实际上并不存在于该位置,有趣的是if (move_uploaded_file($resume['tmp_name'], 'resumes/'))返回true,但文件未移动到该位置。

注意:'resumes/'文件夹存在于控制器的同一目录中。

有什么建议吗?我必须从该视图上传两个文件

修改:https://stackoverflow.com/a/2618432/1528701已解决了我的问题

1 个答案:

答案 0 :(得分:1)

像这样编辑你的用户控制器

public function property() {

 if ($this->request->is('post') || $this->request->is('put')) {
     //die();
     $file = $this->request->data['Document']['submittedfile'];

     //$this->pdfadd1->save($this->request->data);
     move_uploaded_file($this->data['Document']['submittedfile']['tmp_name'], $_SERVER['DOCUMENT_ROOT'] . '/cakephp3/cakephp1/cakephp/app/webroot/files/' . $this->data['Document']['submittedfile']['name']);