One:Before you go to fix an error, it would be nice to know, which error to fix. Add these lines at the top of your script and then try again
ini_set('display_errors',1); error_reporting(E_ALL);
PHP will tell you, what is the problem
for example:Warning: fopen(file/testFile.txt): failed to open stream: Permission denied in /home/suiyc/workspace/sycPro/createFile.php on line 9 can't open file
Two: Can the file is writable? we can use the next code to see if the file is writable.
echo var_dump(is_writable('file/sales.csv')); // file path and file name
Three:change the file mod
// 所有者可读写,其他人没有任何权限 chmod("test.txt",0600); // 所有者可读写,其他人可读 chmod("test.txt",0644); // 所有者有所有权限,其他所有人可读和执行 chmod("test.txt",0755); // 所有者有所有权限,所有者所在的组可读 chmod("test.txt",0740); ?>