【发布时间】:2014-09-08 16:09:58
【问题描述】:
我正在尝试处理通过表单上传的文件并将其保存到我的文件系统。但是,当我这样做时,我总是从Symfony/Component/HttpFoundation/File/File.php 得到一个错误。
Unable to create the "/images/gallery" directory
500 Internal Server Error - FileException
在我的控制器中,我有这段代码,它处理表单验证、实体持久性等。
$gallery_image = new GalleryImage();
$form = $this->createForm(new GalleryImageType(), $gallery_image);
// Bind the posted data to the form
$form->bind($this->getRequest());
// Make sure the form is valid before we persist the image
if ($form->isValid()) {
// Get the entity manager and persist the contact
$em = $this->getDoctrine()->getManager();
$gallery_image->upload();
$em->persist($gallery_image);
$em->flush();
// etc...
}
在upload 方法中我这样做:
$this->image->move('/images/gallery', 'test.'.$this->image->guessExtension());
所以我打算把它移到/web/images/gallery。
我已尝试将/web 更改为777,因此问题似乎不是权限问题。
/web/images/gallery 是放置这些图像的正确位置吗?是否有任何原因导致我无法将此文件保存到文件系统?
【问题讨论】:
-
服务器的错误日志显示什么?
标签: php image forms symfony filesystems