I have to write the information I receive from a form in a text file, and this I tested locally and it worked.
$file = "data.txt";
$data = @fopen($file, "a");
//$data = @fopen("data.txt", "a");
@fwrite($data, "Number: " . $number . " |");
@fwrite($data, " Tittle: " . $tittle . " |");
But when I upload it to the server, the data is not written to the file. I have tried with this:
$data = @fopen("registers/data.txt", "a");
$data = fopen("registers/data.txt", "a");
$datos = fopen("./registers/data.txt", "a");
And nothing works.
In download.php I download the file and it does download correctly but without any information.
<?php
$file = "data.txt";
if(!file_exists($file)) die("I'm sorry, the file doesn't seem to exist.");
$type = filetype($file);
// Get a date and timestamp
// Send file headers
header("Content-type: $type");
header("Content-Disposition: attachment;filename=data.txt");
header("Content-Transfer-Encoding: binary");
header('Pragma: no-cache');
header('Expires: 0');
// Send the file contents.
set_time_limit(0);
readfile($file);
?>
What can I do? I can't find a solution. Help me!