Php Zend Framework映像上载错误:给定的目标不可写
上面是我上传一个文件的代码以及文章。 我得到的错误是Php Zend Framework映像上载错误:给定的目标不可写,php,zend-framework,file-upload,zend-form,lamp,Php,Zend Framework,File Upload,Zend Form,Lamp,上面是我上传一个文件的代码以及文章。 我得到的错误是 //Default Image with article $imgElement = new Zend_Form_Element_File('imgElement'); $imgElement->setLabel("Upload an Image:"); $imgElement->setDestination(APPLICATION_PATH."/../upload/articleImg/");
//Default Image with article
$imgElement = new Zend_Form_Element_File('imgElement');
$imgElement->setLabel("Upload an Image:");
$imgElement->setDestination(APPLICATION_PATH."/../upload/articleImg/");
$imgElement->addValidator('Count',false,1); //ensure only 1 file
$imgElement->addValidator('Size',false,102400); //limit to 100K
$imgElement->addValidator('Extension',false,'jpg,png,gif');
$this->addElement($imgElement);
如果我执行ls-l
,我将获得drwxrwxr-x 3 aman aman 4096 Jul 31 20:03上传
我有权写信给那个局长。如果我使用终端和mv将一些文件发送到那个位置,它就会通过。我想我的应用程序可能无法写入该目录,也许
这是虫子还是什么?
我也试过了。但是没有起作用
An error occurred
Application error
Exception information:
Message: The given destination is not writeable
在主机控制面板中,您需要设置该文件夹的文件权限,使其可写 转到控制面板的文件资源管理器,并在其中进行更改 -或- 如果是本地副本,则需要通过操作系统设置权限 在unix、linux、mac中,这是:
//Default Image with article
$destination = APPLICATION_PATH."/../upload/articleImg";
chmod($destination ,0777);
$imgElement = new Zend_Form_Element_File('imgElement');
$imgElement->setLabel("Upload an Image:");
$imgElement->setDestination($destination);
$imgElement->addValidator('Count',false,1); //ensure only 1 file
$imgElement->addValidator('Size',false,102400); //limit to 100K
$imgElement->addValidator('Extension',false,'jpg,png,gif');
$this->addElement($imgElement);
(从公用/图像/文件夹中)
在windows中,我认为您可以右键单击上载文件夹->属性并取消勾选只读。或者在共享和安全选项中设置权限。您的Web服务器可能没有在上载文件夹上为其设置写入权限的用户或组
aman
下运行。
或者更改文件夹的所有者(www-data
在ubuntu上是默认值)
chmod 777 ./upload
或者给它全局写权限
chown -R www-data ./upload
我推荐第一种解决方案。
-R
是可选的,如果需要,还可以更改上载
文件夹子文件夹的权限。使用此链接解决:
显然,我必须授予网络用户访问权限,即www数据。按照以下步骤操作
chmod -R 777 ./upload
谢谢大家的帮助:)这是一个本地副本,我正在使用ubuntu,当我使用ls-l时,这是dir=>drwxrwxr-x的权限。所以它看起来是可写的,对吧?我从未使用过Ubounto,所以我不知道如何更改权限,但我在他们的comunity网站上找到了这个有用的页面。
sudo usermod -a -G www-data aman
sudo chgrp www-data /home/aman/Work/aman_proj
chmod g+rwxs /home/aman/Work/aman_proj