user3723240
user3723240

Reputation: 393

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");

Upvotes: 0

Views: 5465

Answers (2)

Jeff Clayton
Jeff Clayton

Reputation: 7291

try this:

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

Upvotes: 4

Marcin Nabiałek
Marcin Nabiałek

Reputation: 111829

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.

Upvotes: 3

Related Questions