Quando busco um arquivo .txt para importar me retorna os avisos
Warning: fopen(Clientes.txt): failed to open stream: No such file or directory in /var/www/html/sistemas/help-desk/processa/proc_letxt.php on line 9
Warning: fgets() expects parameter 1 to be resource, boolean given in /var/www/html/sistemas/help-desk/processa/proc_letxt.php on line 12
Warning: fclose() expects parameter 1 to be resource, boolean given in /var/www/html/sistemas/help-desk/processa/proc_letxt.php on line 23
segue codigo:
header('Content-type: text/html; charset=UTF-8');
//local do arquivo
if (isset($_FILES['arquivo'])) {
$arquivo = fopen($_FILES['arquivo']['name'], "r");
// le as linhas do arquivo
while (($linha = fgets($arquivo)) == true) {
// divide os dados com separador "|"
$parte = explode("|", $linha);
// execulta query bd
/*$sql = "INSERT INTO clientes (nome, cpf_cpnj) VALUES ('" . $parte[0] . "', '" . $parte[1] . "', '" . $parte[2] . "')";
$result = mysqli_query($con, $sql);*/
echo "<br>"."CNPJ: " . $parte[0] . "<br>" . "IE: " . $parte[1] . "<br>" . "Nome: " . $parte[2] . "<br>" . "E-mail: " . $parte[3] . "<br>" . "Fone: " . $parte[4] . "<br>" . "CEP: " . $parte[5] . "<br>" . "Logradouro: " . $parte[6] . "<br>";
}
fclose($arquivo);
} else {
echo "erro";
}