//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);
Above is my code to upload a file along with the article. The error I get is
An error occurred
Application error
Exception information:
Message: The given destination is not writeable
If I do an ls -l
, I get drwxrwxr-x 3 aman aman 4096 Jul 31 20:03 upload
I have permission to write to that dir. If I use terminal and mv some file to that location it goes through. I think my application might not have the access to write to that dir maybe ?
Is this a bug or something ? I tried this too. But didn't work
//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);
Solved using this link : https://serversforhackers.com/permissions-users/
Apparently I had to grant the access to the web user i.e. www-data. Followed the steps below.
sudo usermod -a -G www-data aman
sudo chgrp www-data /home/aman/Work/aman_proj
chmod g+rwxs /home/aman/Work/aman_proj
Thanks for help guys :)