phpcopyrenameuncwindows-share

rename a file in php on a windows file server (unc path)


In PHP I want to rename (move/copy) a file on a windows file server: "\myserver\folder1\folder2\myfile.pdf" to "\myserver\folder1\folder2\OLD\myfile.pdf"

(all folders already exist and destination file does not exist)

I tried this:

copy("\\\\myserver\\folder1\\folder2\\myfile.pdf", "\\\\myserver\\folder1\\folder2\\OLD\\myfile.pdf");

and

copy("//myserver/folder1/folder2/myfile.pdf", "//myserver/folder1/folder2/OLD/myfile.pdf");

I receive:

[function.copy]: failed to open stream: Permission denied 

The computer I am on / user logged in as has permissions to rename/move/delete/copy to that share/folder.

I am guessing I need to somehow give php permissions, or run php as my user? OR?


Solution

  • PHP will be running as whatever user your web server runs as. You would need to grant permissions on that folder to whatever user account that is.