I have a PHP script that writes some rows to a CSV file:
$fp = fopen($csv, 'w');
I'm using mode 'w' so that it will create the file if it doesn't exist, however the file is automatically given 644 permissions even though I gave 777 to the whole /var/www/html/ directory (not a good idea but suitable for testing).
How can I write to the file and give it permissions beforehand? Or is there a better way to give write permissions?