Boa tarde, to tentando importa o conteúdo de um arquivo .txt para meu DB, e conseguir isso ja..
mais queria uma barra de progresso de 0 a 100 %, pq o arquivo é grandinho, tem 15000 linhas ou as vezes tem mais..
so que quando importo do jeito que to fazendo a barra anda muito rapido, e importa, mais não da ngm msg de error e nem de sucesso , e tbm aceita qualquer tipo de arquivo e se o txt tiver 0 linhas ele tbm enche a barra com 100% ...
poderiam me ajudar a colocar um barra de progresso com msg e tbm que demore o tempo normal..
Segue o Codigo que estou usando..
<?php include('../conexao.php'); if(isset($_POST['BT_Enviar'])){ $data = $_POST['data']; $nometmp = $_FILES['buscar']['tmp_name']; $arquivo = $nometmp;// aquivo a ver importado txt $arq = fopen($arquivo,'r');// le o arquivo txt while(!feof($arq)) for($i=0; $i<1; $i++){ if ($conteudo = fgets($arq)){//se extrair uma linha e não for false $ll++; // $ll recebe mais 1 ==== em quanto o existir linha sera somada aqui $linha = explode(';', $conteudo);// divide por coluna onde tiver ponto e virgula } $sql = "INSERT INTO db_claro (`Tel`, `Secao`, `Data`, `Hora`, `UF`, `Numero`, `Duracao`, `Tarifa`, `Valor`, `MesComp`) VALUES ('$linha[0]', '$linha[1]', '$linha[2]', '$linha[3]', '$linha[4]', '$linha[5]', '$linha[6]', '$linha[7]', '$linha[8]', '$data')"; $result = mysql_query($sql) or die(mysql_error()); //$linha = array();// limpa o array de $linha e volta para o for }if($sql){ $sql3 = "INSERT INTO mes (`mescomp`) VALUES ('$data')"; $sql1 = "UPDATE db_test SET tel = REPLACE(tel, ' ','')"; $sql2 = "UPDATE db_test SET tel = REPLACE(tel, '-','')"; $result1 = mysql_query($sql1) or die(mysql_error()); $result2 = mysql_query($sql2) or die(mysql_error()); $result3 = mysql_query($sql3) or die(mysql_error()); } else{ $erro1 = "Não foi possivel Importar"; } $contlinhas = "Quantidade de linhas importadas = ".$ll; } ?> <!doctype html> <html> <head> <meta charset="iso-8859-1"> <title>Gerenciador</title> <link href="../estilo.css" rel="stylesheet" type="text/css"> <link href="bootstrap.css" rel="stylesheet" type="text/css"> <script src="jquery.js"></script> <script type="text/javascript" src="carregar.js"></script> <script type='text/javascript'> $('#form').ajaxForm({ uploadProgress: function(event, position, total, percentComplete) { $('progress').attr('value',percentComplete); $('#porcentagem').html(percentComplete+'%'); }, success: function(data) { $('progress').attr('value','100'); $('#porcentagem').html('100%'); $('pre').html(data); } }); </script> </head> <body> <?php /*=================INICIA A SESSAO DO USUARIO========================================================*/ session_start(); if((!isset ($_SESSION['UsuarioNome']) == true) and (!isset ($_SESSION['senha']) == true)) { unset($_SESSION['UsuarioNome']); unset($_SESSION['senha']); header('location:index.php'); } $logado = $_SESSION['UsuarioNome']; $numero=$_SESSION['UsuarioNumero']; $data = date("d/m/Y"); /*===========CONEXÃO===================*/?> <div id="top"> <div id="topo"> <p>Olá, <?php echo $logado?></p> Data: <?php echo $data?><br /> <a href="logout.php">Sair</a> </div><!--TOPO--> </div><!--TOP--> <div style="width:1000px; margin-left:auto; margin-right:auto"><br /> <?php if(isset($contlinhas)){ print '<div style="width:80%; background:#0093FF; color:#fff; padding: 5px 0px 5px 0px; text-align:center; margin: 0 auto;">'.$contlinhas.'</div>'; }if(isset($erro1)){ print '<div style="width:80%; background:red; color:#fff; padding: 5px 0px 5px 0px; text-align:center; margin: 0 auto;">'.$erro1.'</div>';} ?> <br /> <form action="teste.php" method="post" enctype="multipart/form-data" name="form" id="form"> <!-- DADOS PESSOAIS--> <fieldset id="fieldset"> <legend>Importação</legend> <table cellspacing="10"> <td> <label for="nome">Arquivo: </label> </td> <td align="left"> <input type="file" name="buscar" /> </td> <br ><br > <progress value="0" max="100" class="progress progress-striped" role="progressbar" style="width:100%;" ></progress><span id="porcentagem">0%</span> <tr> <td> <label for="images">Data Competente: </label> </td> <td align="left"> <input name="data" type="date" title="Coloque a Data do vencimento da Conta" /> </td> </tr> </table> </fieldset><br /> <input type="submit" name="BT_Enviar" id="BT_Enviar" value="Enviar" onClick="start();"/> </form> </div> </body> </html>
alguém tem ideia ai?