PHP file upload that passes data to MYSQL

0

It will be difficult to explain what I want but I will try to summarize it in 2 small paragraphs.

Come on

I have a script that passes data from file .CSV and .TXT to database MYSQL , but it only works when I put the name of my document itself and the document itself hosted with it, that is, I have a file importar.csv and importar.php , in importar.php must be set to importar.csv .

But what do you want to do?

I would like it to work with php upload, that is, the person (anyone) who has access to the upload area, send the file .CSV or .TXT and instead of the file importar.php setar o file importar.csv , it sets the upload file.

If you do not understand, please leave a comment that I explain better.

And importar.php how are you?

$tabela = "n_emails";
$arquivo = 'importar.csv';

$arq = fopen($arquivo,'r');

while(!feof($arq))
for($i=0; $i<1; $i++){
if ($conteudo = fgets($arq)){
    $ll++; // $ll 
    $linha = explode(';', $conteudo);// 
}

$sql = "INSERT INTO $tabela (ativo, email) VALUES ('$linha[0]', '$linha[1]')";
$result = mysql_query($sql) or die(mysql_error());
$linha = array();
}
echo "quantidade de linhas importadas = ".$ll;

I hope you have passed all the information necessary for everyone's understanding, thank you for the help or the attempt haha.

    
asked by anonymous 28.03.2016 / 15:09

0 answers