Hi programming gurus, Would like to get some help on this problem. I'm using php to make a copy of a file. After copying, I realized two things. 1. The new file does NOT the same chmod permission as the original (It's 0644 instead) 2. The new file does NOT the same owner/group as the original (It's null/empty instead) I can't use chmod, chgrp or chown on the new file because it is 0644. Can anyone help me? I just want a simple command to duplicate a file. Cheers! Jimmy
If the standard function 'copy' is causing problem. Then we may give a try to following (make sure files you copy are not too large and are not very often copied): #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 chmod chmod($target_file_path, 0777); Code (markup): I hope this helps. regards
Ok now copied file has the SAME permission as the source! But it's Owner/Group is still null/empty. When I try to run chown or chgrp, it gave these error message: "Operation not permitted" Why can't I change the owner/group of the file with 777? Any advice? Jimmy
The folder you are copying to, does that folder have permissions already set. Please check that first through FTP. And then let me know results. regards
Yes! The folder is set to 777. I just want to duplicate a file to the same folder (with permission, owner, group intact). Why it is so hard to do so? Argh...
Thanks mate! That helps a lot Since I'm exposing my username/password of my server within the code, any ideas how to secure it?
The only method I can think of is to upload the script to the server when you need to use it, and delete it afterwards. Otherwise I don't think there's much other ways to secure it, but there might be.