demuro1
demuro1

Reputation: 299

error when trying to write file

I am trying to write a file. I keep getting an error though and I'm not sure what to make of it. Is there anyone who has an suggestions on this. Thanks so much The error:

Warning: fopen(Library/WebServer/Documents/gasDev/test_files/850_855_csv_tests/855_export/GUNB0855.Z9000404): failed to open stream: No such file or directory in /Library/WebServer/Documents/gasDev/src/controller/containerController.php

this is the function I am using:

public function saveFile($saveFile,$content){
    $newFile = fopen($saveFile, 'w');
    fwrite($newFile, $content);
    fclose($newFile);
}//end saveFile()

Upvotes: 0

Views: 44

Answers (1)

exussum
exussum

Reputation: 18550

You cant read or write to a directory which doesnt exist. Code in this answer should be run before trying to open it

PHP: fopen to create folders

Upvotes: 2

Related Questions