Question

when I run my page on my local host it does not create the file. I have given read and write permissions to the folder site. i have used system and exec functions and when i run the page via the terminal it creates a file but via my browser it doesnt.

$my_file = '/var/www/site/file.txt';
$handle = fopen($my_file, 'w') or die('Cannot open file:  '.$my_file); 
Était-ce utile?

La solution 2

Did you try with a relative adresse?

$my_file = 'site/file.txt';

Autres conseils

The following commands will correctly apply permissions to the directory.

cd /var/www/site
sudo chmod 664 *
sudo find . -type d -exec chmod 755 {} \;

If the error persists, please post any PHP errors that are thrown.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top