I want to give directory permissions not to an user, but to a file which contains php code. Is it possible ? something like chmod 777 directory_name -> file.php
try this
<?php
chmod("/somedir/somefile", 755); // decimal; probably incorrect
chmod("/somedir/somefile", "u+rwx,go+rx"); // string; incorrect
chmod("/somedir/somefile", 0755); // octal; correct value of mode
?>
here /somedir/somefile
is your file path and read this article
You can not give a specific file access to a path, only a user or a usergroup
you could maybe create a separate user and use it to execute the file.