Jump to content

How to copy/duplicate file with owner/group intact?


phq

Recommended Posts

Goodday!

 

This is my current code:

 

#read first
$data = implode("",file($source_file_path)); //equvilant to 'file_get_contents', all php4 dist. dont have this

#write copy
$f = fopen($target_file_path,"w");
fwrite($f,$data);
fclose($f);

#then change owner/group
chown($target_file_path, $ownergroup);
chgrp($target_file_path, $ownergroup);

 

I manage to duplicate the file with the SAME permission as the source.

But I can't run chown/chgrp. It says "Operation not permitted..."

 

Any advice? Thankslots

 

PHQ

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.