When I use the script below it only works the first time it runs. When I try again it does not send the file, it just writes locally. Because? I'm using ftp_close
, is not that enough?
When I change the host, it works only for the first time.
//Definição do arquivo local
$arq = "p";
$arq .= date("YmdHis");
$arq .=".txt";
//Escreve o arquivo local
file_put_contents($arq,$conteudo_file);
//Conecta no server remoto e loga
$dados = array(
"host" => "ftp.testes.com",
"usuario" => "user",
"senha" => "password");
$fconn = ftp_connect($dados["host"]);
ftp_login($fconn, $dados["usuario"], $dados["senha"]);
//envia arquivo para o server remoto
ftp_chdir($fconn, "DataIn");
ftp_put($fconn, $arq, $arq, FTP_BINARY);
ftp_close($fconn);
unlink($arq);