I wrote a script to download the file to the server from the client.

The file is loaded, but not moved from the temporary files directory to the directory I need. Writes failed to open stream: Permission denied in (the address of the script that handles the movement) on line 20. and below the second error Unable to move / tmp / phpblablabla to (directory to move the file)

I will say right away that I smoked the manuals on php.net about the move_uploaded_file function and wrote as they recommend there considering all the wishes.

The file is not copied!

  • also worked with chmod for the script and the file being loaded. and used a similar utility for folders only. nothing helps. maybe there’s a problem somewhere in the php.ini file, but I don’t know what to fix there. - lap top
  • Perhaps the problem is in the file php.ini where the maximum file size is indicated? Although it may not matter! - Palmervan

1 answer 1

It seems to me that the whole thing is about php user, see which user and group of files in the temporary directory and try to give him the right to access the desired folder. Use chown to change user and group. The command syntax, in my opinion, is:

chown user:group /var/www/* -R. 

And, in general, man chown

Alternatively, if the axis is Red Hat or Centos - then disable selinux.

 setenforce 0 
  • Is php such a user? I have / tmp and / var / www / root. The server starts under the root. I have Linux Ubuntu - lap top
  • with the rights does not come out. but noticed one nonsense. when a site uploads a file, it places it in / tmp instead of / var / www / temp which I specified in upload_tmp_dir - lap top