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 - PHP Tutorial
From the course: PHP Techniques: Working with Files and Directories
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
-
-
-
-
-
(Locked)
Configuring PHP for file uploads1m 52s
-
(Locked)
Sending files as form data3m 51s
-
(Locked)
Inspecting uploaded files4m 54s
-
(Locked)
Moving uploaded files5m 7s
-
Handling upload errors4m 2s
-
(Locked)
Setting file permissions6m 7s
-
(Locked)
Securing file uploads2m 15s
-
(Locked)
Challenge: Profile photo3m 48s
-
(Locked)
Solution: Profile photos4m 3s
-
(Locked)
-