简体   繁体   中英

PHP copy a file and change the permissions of the copy

I am using php copy() function and it works fine, the only thing is when I copy the file the permissions are set to: -rw-r--r-- and I would like to make them readable and writable (777)

is this possible?

copy("../virtual-tours/PTGuiViewer.js", "../virtual-tours/" . $brandNewFolderName . "/PTGuiViewer.js");

尝试这个:

chmod("full-path-of-file",0777); 

You need to use chmod as below:

copy("../virtual-tours/PTGuiViewer.js", "../virtual-tours/" . $brandNewFolderName . "/PTGuiViewer.js");
chmod("../virtual-tours/" . $brandNewFolderName . "/PTGuiViewer.js", 0777);

Notice: Leading zero in 0777 is important.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM