Change file permissions dynamically with php
A tutorial to change file permissions dynamically with php
A tutorial to change file permissions dynamically with php
first define the function name in this case call it change Permissions with two parameters $path is the path to the folder and $modlevel is the permissions level to use.
<?php function changePermissions($path,$modlevel){ ?>
Then using the command chmod we change the file permissions
<?php chmod($path,$modlevel); ?>
then do an if statement to see if it’s worked or failed this is optional
<?php if(chmod){ echo "success"; } else { echo "failed"; } ?>
to run the function you need to call it, you call it by typing it’s name with the parameters
<?php changePermissions("assets/images/uploads/",777); ?>
here’s the full script:
<?php function changePermissions($path,$modlevel){ chmod($path,$modlevel); if(chmod){ echo "success"; } else { echo "failed"; } } changePermissions("assets/images/uploads/",777); ?>
That’s it now you should be able to change file permissions dynamically with php.







Discussion
No responses to "Change file permissions dynamically with php"
There are no comments yet, add one below.
Leave a Comment