![Ygor Amaral Ygor Amaral](//static.vivaolinux.com.br/imagens/fotos/desconhecido.png)
ygor.amaral
(usa Ubuntu)
Enviado em 14/10/2010 - 21:24h
Galera, meu apache não está conseguindo escrever arquivos.
Rodei o código abaixo, e ele só exibe "The file text.txt is not writable".
Já dei um "chmod 777" tanto no arquivo quanto na pasta toda... e nada...
Acho que é alguma configuração do Apache, alguém sabe dizer?
Utilizo o Fedora 13.
Abraço.
---------------------------
$filename = 'test.txt';
$somecontent = "Add this to the file\n";
// Let's make sure the file exists and is writable first.
if (is_writable($filename)) {
// In our example we're opening $filename in append mode.
// The file pointer is at the bottom of the file hence
// that's where $somecontent will go when we fwrite() it.
if (!$handle = fopen($filename, 'w')) {
echo "Cannot open file ($filename)";
exit;
}
// Write $somecontent to our opened file.
if (fwrite($handle, $somecontent) === FALSE) {
echo "Cannot write to file ($filename)";
exit;
}
echo "Success, wrote ($somecontent) to file ($filename)";
fclose($handle);
} else {
echo "The file $filename is not writable";
}
----------------------