我是整个启动现场的新手,我正在尝试修复我的文件上传,它似乎是在捆绑中上传文件。我需要将文件上传到捆绑包外的public_html文件夹。
以下是我的功能,我需要更改哪些内容路径超出symfony项目文件夹?
服务器文件夹设置:
/etc/
/symfony project folder
/public_ftp/
/public_html/ <--- this is where I want it to go
public function getUploadDir()
{
return 'images/';
}
public function getUploadRootDir()
{
return __DIR__ . '/../../../../web/' . $this->getUploadDir();
}
public function getWebPath()
{
return null === $this->image ? null : $this->getUploadDir() . '/' . $this->image;
}
public function getAbsolutePath()
{
return null === $this->image ? null : $this->getUploadRootDir() . '/' . $this->image;
}
答案 0 :(得分:1)
将您的getUploadRootDir
更改为:
public function getUploadRootDir()
{
return __DIR__ . '/../../../../../public_html/' . $this->getUploadDir();
}
这会将您的图片放入public_html/images/
,如果您希望将它们直接放在public_html
中,那么还会将getUploadDir
更新为:
public function getUploadDir()
{
return '';
}