File_put_contents returns true, but file doesn't write either.
I have a small PHP script that runs when I click a button on some HTML page:
<?php
if(isset($_POST['field1'])) {
$data = $_POST['field1'] . "\n";
$ret = file_put_contents('/tmp/mydata.txt', $data, FILE_APPEND | LOCK_EX);
if($ret === false) {
die('There was an error writing this file');
}
else {
echo "$ret bytes written to file";
}
}
else {
die('no post data to process');
}
When I give html some text and run the script, I get an echo:
16 bytes written to file
However, when I then open the file, it is empty and reads as "zero bytes" in size.
I tried communicating with permissions and checking the log files without prompts, I made sure the private text gets to the php script. I'm completely stumped, any suggestions?
+3
NNNNNNNNNNDelicious
source
to share
No one has answered this question yet
Check out similar questions:
691
4
2
1
0
0
0
0
0
0