From the course: PHP Techniques: Working with Files and Directories

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Setting file permissions

Setting file permissions - PHP Tutorial

From the course: PHP Techniques: Working with Files and Directories

Start my 1-month free trial

Setting file permissions

- [Instructor] Now that we know how to upload files, I want us to revisit the subject of file permissions. This time, we'll learn how to set file permissions using PHP. When we talked about file permissions earlier, we are mostly concerned with ensuring that PHP could access files created by other users. But what about the other way around? How can we make sure that other users can access files uploaded through PHP? The web server may run as a different user, and users may not have permission to access files that PHP creates, but PHP can set the owner and the permissions as needed. Let me demonstrate. Earlier, I uploaded a file that was sonnet.txt originally, and you can see it here in the uploads directory as sonnet.txt. If we go into the Unix console, you'll see that they have different owners and different permissions. Here's sonnet.txt, it's owned by Kevin Skoglund, and everyone has read, write, and execute…

Contents