sometimes I receive/downlad .pdf files without the "other" group. I mean -rw-r----- 1 root root 12889 Mar 26 16:41 Document.pdf. I need to work them via php scripts (read, move,...) but I cant do it because the owner is root:root while php script is www-data:www-data. I googled the whole internet but was unable to find a solution. I tried with php internal commands and/or exec(), shell_exec(), system() but the result was a big hole in the water.
This is a piece of code I use. Inverting the order of the operations has no effect
$new_name = str_replace(' ','',$fname);
$new_name = preg_replace('/\(|\)/','',$new_name);
$command = 'sudo cp $full_fname $dir.$new_name';
$copy = shell_exec($command); //, $output, $retval);
$ch_perms = 'sudo chmod a+rw '. $dir.$new_name;
$permiss = exec($ch_perms, $output, $retval);
Even chown has no effect.
Any help will be really appreciated tnx