Question
file_put_contents won't write data anywhere
I have some php scripts that dump certain data to disk so that a user can later, optionally, download them. This worked fine on my local development machine but is not working on my DigitalOcean droplet.
Boiled down, the code looks like
<?php
file_put_contents("./onedot.txt" , "?");
file_put_contents("../twodots.txt" , "?");
file_put_contents("./pro/dotslashpro.txt" , "?");
file_put_contents("/slash.txt" , "?");
echo 'tried it';
?>
The code runs but none of these files get created
an alternate implementation based around fopen() and write() resulted in a “can’t open file” error.
I presume there is some setting in Apache or in Debian that I need to change. Any suggestions?
These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.
×