ho fatto una prova che non avevo mai fatto...
il primo è quello che conosco e che sono sicuro funzioni sempre:
codice:
$filename = 'test.txt';
if (is_writable($filename)) {
if (!$handle = fopen($filename, 'a')) {
echo "Non si riesce ad aprire il file ($filename)";
exit;
}
if (!fwrite($handle, $somecontent) ===FALSE) {
echo "Non si riesce a scrivere nel file ($filename)";
exit;
}
fclose($handle);
}
$len = filesize($filename);
header('Content-type: text/plain');
header('Content-Length: $len');
header('Content-Disposition: attachment; filename="nomechevuoidarealfilequandovienesalvato.txt"');
readfile($filename);
il secondo è questo
codice:
header('Content-type: text/plain');
header('Content-Disposition: attachment; filename="nomechevuoidarealfilequandovienesalvato.txt"');
echo "prova";
ciao