0

我正在尝试上传文件并将其放在我的web/uploads/produits/img目录中,但下面的代码不起作用:

public function getUploadDir()
{
    return 'uploads/produits/img';
}
protected function getUploadRootDir()
{
    return __DIR__.'/../../../../web/'.$this->getUploadDir();
}

我收到以下错误:

Could not move the file "C:\wamp\tmp\php9265.tmp" to "C:\wamp\www\Projet\src\Arkiglass\ProduitBundle/../../../..\web/uploads/produits/img\." (move_uploaded_file() 
[function.move-uploaded-file]: Unable to move 'C:\wamp\tmp\php9265.tmp' to 'C:\wamp\www\Projet\src\Arkiglass\ProduitBundle/../../../..\web/uploads/produits/img\.') 

它似乎不知道目录__DIR__.'/../../../../web/'...

4

1 回答 1

0

您的实体似乎不在实体目录下,而是直接在 bundles 目录下。可以?所以你要上升一个目录。两种选择:

  1. 在子文件夹中移动您的实体Entity,调整命名空间和所有引用。标准的 symfony 包目录布局。
  2. 删除一级../
于 2013-05-19T15:15:39.213 回答