1
When I search a file . txt to import me returns the warnings
Warning: fopen(.txt Clients): 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
follows code:
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";
}