how upload using php code with file permissions in ubuntu

Problems with the Linux version of XAMPP, questions, comments, and anything related.

how upload using php code with file permissions in ubuntu

Postby sreekar1 » 31. March 2020 05:56

how upload using php code with file permissions in ubuntu
sreekar1
 
Posts: 12
Joined: 22. March 2020 12:06
XAMPP version: 5.6.20
Operating System: lubuntu

Re: how upload using php code with file permissions in ubunt

Postby Nobbie » 31. March 2020 11:14

The target/upload folder must have sufficient rights to allow Apache to create files in that folder. Apache (and PHP) runs with the User and Group as defined in httpd.conf. The file itself should have sufficient rights for Apache to read it, if it is used for HTTP Request later on.

The default rights for a newly created file are defined by the "umask" command in Linux. It is the umask in the context of the Apache User (see above). In new Xampp installations usually the User is set to "daemon", same for the Group. See the manual for umask. You can modify file rights after upload in the upload PHP script via chmod() function: https://www.php.net/manual/en/function.chmod.php

You may also change User and Group of Apache to your needs, for example i created a new User "xampp" in my Linux and assigned Apache to run with "xampp". I also changed ownership of htdocs to "xampp" etc., I also assigned the htdocs folder as home folder for User "xampp", then finally i can use FTP Server with User "xampp" to put files via FTP onto my htdocs folder (some tools like WordPress need that).
Nobbie
 
Posts: 11620
Joined: 09. March 2008 13:04


Return to XAMPP for Linux

Who is online

Users browsing this forum: No registered users and 9 guests

cron