Reputation: 109
I have a webserver set up on a business network. I am using php to create a file and I want to write it to a local client shared folder also on the network. When I ping from the client I get a response from the webserver. When I ping from the webserver I get a response from the client. Here's my code. I am getting a permissions error. Any ideas what could cause that? Is the path correct? How do I formulate the path?
$fileName = "\\\\7PD01-2012.payday.local\\PTBurnJobs\\file.txt";
var_dump($fileName);
if (($myfile = fopen($fileName, "w+")) === false) { //open the file
//if unable to open throw exception
throw new RuntimeException("Could Not Open File Location.");
}
foreach($arr as $line){
fwrite($myfile, $line . PHP_EOL);
}
fclose($myfile);
Would it be more prudent to create the file on the webserver and then transfer it to the client? How would I do that?
Upvotes: 2
Views: 45
Reputation: 1397
If you are getting a permissions error, then you will need to check that the user your php script/webserver is running under has write permissions in the client folder.
A question for you: How do you know you are getting a permissions error? The code above does not check why something failed, only that it failed.
If you are getting a permissions error, then it sounds like a successful connection is being made, and you're at least attempting to transfer the file successfully, only getting blocked by your ACL layer.
Upvotes: 1