0
Colleagues.
I need to popular a table with a CSV file and I am using a simple PHP/Mysql code for this. But even with 755 permission in the file, I can’t. It says that the file could not be found. Follow the code:
// PHP
if($_POST){
$arquivo = $_FILES['Arquivo']['name'];
$arquivoTemp = $_FILES['Arquivo']['tmp_name'];
$diretorio = "arquivo/".$arquivo;
move_uploaded_file($arquivoTemp, $diretorio);
$abrirArquivo = fopen(basename($_FILES['Arquivo']['tmp_name']), "r");
if (!$abrirArquivo){
echo "arquivo não encontrado!"; // Ele para aqui!
}else{
while ($valores = fgetcsv ($abrirArquivo, 2048, ";")) {
//aqui faço a inserção
}
}
}
// HTML
<form method="post" enctype="multipart/form-data">
<table width="500px" border="1" style="border-collapse: collapse">
<tr>
<td><input type="file" name="Arquivo"></td>
<td><input type="submit" name="Enviar" value="Enviar"></td>
</tr>
</table>
</form>
Do you have any debug type? Xdebug? puts the fixed file path in a variable to test.
– Gabriel Rodrigues