Reputation: 897
Here is my code
<!DOCTYPE html>
<html>
<body>
<?php
$v=fopen("exc.csv", "a")or die("Unable to open file!");
fwrite($v,"appended txt\r\n");
fclose($v);
?>
</body>
</html>
it is working perfectly but whenever I try to run this code while exc.csv file is open in my computer, I'm getting this error:
Warning: fopen(exc.csv) [function.fopen]: failed to open stream: Permission denied.
I've already tried using chmod() and setting the permission to 0777 and its still not working. Is there any way that I can write into a file while it is physically open? If not, please tell me why.
Upvotes: 1
Views: 293
Reputation: 2636
As far as I am aware of it is not possible - or at least not on Windows. The thing is the file is already locked by another process. As soon as you open a file for editing in an editor, it is read only for all other processes. The reason is to prevent collision of two processes modifying the same file.
Upvotes: 1