Tuesday, November 16, 2021

[SOLVED] move_uploaded_file gives “failed to open stream: Permission denied in /var/www/html”

Issue

I am trying to upload files to a Redhat server, but am getting this error:

failed to open stream: Permission denied in /var/www/html

I modified permits in all of the folders and it still doesn't work. Can anyone guide me?

My app works if I run it in a localhost, but in the server it just doesn't work.

I'm working with: Redhat v7, PHP version 5.4.16, wamp version 2.2

I've modified php.ini and httpd.conf as in another answers I read, but with no results.


Solution

O_o wowow be quiet, no 777 !!! Others write no!! Protect your folder first with deny from all, require valid user...

Or if your folder is public, understand how do it with no 777 perms:

  • Show which user or group uses apache to run itself, in environment variables of apache config files.

  • Change owner or group of the folder you whould be upload files, and set write perms to the group or to the user.

You have various options, one of this, for example: chown myftpuser.www-data upload/ chmod g+w upload/ When you upload files apache runs over www-data group, and it have permisions to write inside folder



Answered By - David