Reputation: 671
//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);
Upvotes: 1
Views: 3482
Reputation: 671
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 :)
Upvotes: 0
Reputation: 4273
Your webserver is probably not running under the user or group aman
for which the write permissions are set on the upload folder.
Either change the owner (www-data
is default on ubuntu) of the folder
chown -R www-data ./upload
or give it global write permissions
chmod -R 777 ./upload
I would recommend the first solution.
The -R
is optional and changes also permissions on subfolders of your upload
folder, if required.
Upvotes: 1
Reputation: 86
in your hosting control panel, you need to set the file permissions for that folder so it is writable.
Go to the control panel's file explorer and change it in there.
-OR-
If it is your local copy, you need to set the permissions through your OS.
in unix, linux, mac, this is:
chmod 777 ./upload
(from within the public/images/ folder)
In windows I think you either just right click the upload folder -> properties and un-tick read only. Either that or set the permissions in sharing and security options.
Upvotes: 1