JCm JCm - 1 year ago 194
Linux Question

The upload destination folder does not appear to be writable even with (seem to be) correct file permissions

I already looked into many similar question on this forum but none seem to solve my problem.

I will list at the bottom some of the question page I viewed on this forum, but let me lay my situation on this question first.

I am using codeigniter v 2.x
PHP 5.5.32
MariaDB 5.5.44
CentOS 7.2.1511

Below is the location of my application vits.

[root@VITSServer html]# pwd
[root@VITSServer html]# ls -al
total 16
drwxrwxr-x. 6 apache apache 92 Nov 9 17:55 .
drwxr-xr-x. 4 root root 31 Nov 20 2015 ..
-rwxr--r--. 1 apache apache 1150 Oct 28 2015 favicon.ico
-rwxrwxrwx. 1 apache apache 20 Oct 12 2015 info.php
drwxrwxr-x. 11 apache apache 4096 Oct 27 2015 laravel5
drwxr-xr-x. 2 apache apache 22 Oct 14 2015 test
drwxrwxr-x. 7 apache apache 4096 Nov 10 11:16 vits
drwxr-xr-x. 3 apache apache 17 Nov 9 17:56 vits_v2.0
[root@VITSServer html]#

Next below is inside the vits directory

[root@VITSServer vits]# ll
total 1504
drwxrwxr-x. 15 apache apache 4096 Nov 9 17:27 application
drwxrwxr-x. 7 apache apache 4096 Nov 9 18:01 assets
drwxrwxrwx. 4 apache apache 8192 Nov 9 18:08 files
-rwxrwxr-x. 1 apache apache 6452 Nov 9 17:50 index.php
drwxrwxr-x. 8 apache apache 4096 Nov 9 17:27 system
-rwxrwxr-x. 1 apache apache 1503295 Nov 9 17:27 vits_db.sql

my upload path is in the "files" directory. as seen above, I already set it to 777 and owner:group to apache. How ever my upload still returns an error stating "The upload destination folder does not appear to be writable".

I checked my php_info and it seems everything should have been ok.

enter image description here

The question now is, am I missing something here?

stackoverflow page I already viewed:

Answer Source

Just figured it out.

Apparently my selinux is preventing it to be uploaded even with the correct permission and ownership.

I disabled my selinux with the ff command:

setenforce 0


Alternatively, in order to retain your selinux status as enabled, we can change the context of our target upload directory.

There are 2 ways:

  1. via chcon command. However, changes made with the chcon command do not survive a file system relabel, or the execution of the restorecon command

  2. via semanage fcontext. Which is a persistent change.

Hope this would help others too.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download