【发布时间】:2012-12-02 08:29:56
【问题描述】:
我正在尝试使用食谱示例来了解如何使用 symfony2 上传文件: http://symfony.com/doc/2.0/cookbook/doctrine/file_uploads.html
问题是我无法获取 web 文件夹的路径。
这里有一些细节:在我的网络文件夹中,我有这样的结构:
/web
/bundles
/sciforumversion2
/images
从实体中,我尝试获取文件夹路径并将图像保存在 /images 文件夹中
为此,我正在使用:
protected function getUploadRootDir()
{
// the absolute directory path where uploaded
// documents should be saved
return __DIR__ . '/../../../../web/'.$this->getUploadDir();
}
protected function getUploadDir()
{
// get rid of the __DIR__ so it doesn't screw up
// when displaying uploaded doc/image in the view.
return 'sciforumversion2/bundles/images';
}
但是我得到了无法创建目录的异常:
Unable to create the "/home/milos/workspace/conference2.0/src/SciForum/Version2Bundle/Entity/../../../../web/sciforumversion2/bundles/images/conference" directory
欢迎任何关于我如何获取网络文件夹 url 以及为什么 symfony 食谱提出的解决方案不起作用的想法。
非常感谢。 谢谢。
【问题讨论】:
-
谢谢,但除了目录问题之外,我的个人捆绑包中的一切都在工作,所以我更喜欢使用我拥有的东西
标签: php symfony path doctrine-orm