I need to separate each string so I can import it into the database, how would I do it?
link of the file which I am testing link
<?php
include_once("../conn/conexao.php");
if ($_SERVER["REQUEST_METHOD"] === "POST") {
$filename = $_FILES["file1"];
if ($filename["error"]) {
throw new Exception("Error: ".$filename["error"]);
}
$dirUploads = "../uploads";
if (move_uploaded_file($filename["tmp_name"], $dirUploads . DIRECTORY_SEPARATOR . $filename["name"])) {
echo "Upload Realizado com sucesso";
}else {
throw new Exception("Não foi possivel fazer o upload.");
}
}
$filename = $dirUploads . DIRECTORY_SEPARATOR .
$filename["name"];
if(file_exists($filename)) {
$file = fopen($filename, "r");
$headers = explode(",", fgets($file));
$data = array();
while ($row = utf8_encode(fgets($file))) {
$rowData = explode(",", $row);
$linha = array();
for ($i = 0; $i < count($headers); $i++) {
$linha[$headers[$i]] = $rowData[$i];
}
array_push($data, $linha);
//$query1 = mysqli_query($conn, "INSERT 'clientes' SET nome='$row[1]', responsavel = '', endereco = '$row[4]', endereco_entrega = '', cpf = '$row[12]', telefone = '', cidade_estado = '', ie = '', cep = ''") or print mysql_error();
}
echo "<br>";
/*if ($query1) {
echo "Tudo certo";
}else {
echo "erro";
}
echo "<br>";*/
fclose($file);
//echo json_encode($data);
//var_dump($data);
}
?>