【问题标题】:file not uploading, not moving cakePHP文件不上传,不移动 cakePHP
【发布时间】:2013-09-06 09:55:04
【问题描述】:

在我的 cakePHP 项目中,在上传文件时,遇到以下问题:

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

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

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

编辑:https://stackoverflow.com/a/2618432/1528701 解决了我的问题

【问题讨论】:

  • 如果你在linux或Mac上,检查resume文件夹的chmode,并将其更改为777
  • 遗憾的是这适用于 windows7
  • 已经检查了表格的enctype???您应该在表单中添加enctype="multipart/form-data"

标签: php cakephp file-upload


【解决方案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']);

【讨论】:

  • 更改为if (move_uploaded_file($resume['tmp_name'], $_SERVER['DOCUMENT_ROOT'] . '/rm/app/webroot/files/')) { is throwing move_uploaded_file() [function.move-uploaded-file]: copy() 函数的第二个参数不能是目录
猜你喜欢
  • 1970-01-01
  • 2013-12-26
  • 2013-08-14
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2012-08-16
  • 2011-01-14
相关资源
最近更新 更多