This error is because of permission error. Most probably your
Apache web server is running using a different user* and the *htdocs* folder in which the code is saved is created using another user, hence Apache is not allowing PHP to create a file or directory.
1. Check the user for apache process by running the following command in terminal: ps aux | grep httpd
. The first column will be the owner typically it will be *nobody* or in the case of bitnami it can be *daemon.
2. Now change the owner of the directory in which you want to create and move a file. The owner should be the same as we found in the step 1. If the user is
daemon
, then run the following two commands.
sudo chown daemon /path/to/directory/
where, daemon is the user, then run the below command to change the mode of the folder,
chmod -R 0755 /path/to/directory/
And you should be good to go. Hope this helps.