LEER UN ARCHIVO EN EL CLIENTE Y MIGRAR LA LECTURA A UNA TABLA(con codigo)
<table width="75%" border="0">
<tr>
<td>MIGRACION DE ARCHIVO A BASE DE DATOS</td>
<td>Â </td>
</tr>
<tr>
<td>Previsualizaciòn de Resultados</td>
<td>Â </td>
</tr>
</table>
<?php
//include("librerias/conexion.php");
//$conexion=conexionBD() ;
//pREVISUALIZACION ANTES DE COMENZAR TODA LA INSERCION
$fd = fopen ("prueba.txt", "r");
$buffer = fgets($fd,100);
//se lee la longitud de cada campo
$sql=\'SELECT * FROM campos \';
$result=mysql_query($sql,$conexion);
echo \'<table width="75%" border="1">\';
echo \'<tr>\';
$i=1;
echo $buffer.\'<br>\';
while ($row=mysql_fetch_array($result))
{
echo \'<td>\';
echo \'[\'.$i.\']\';
echo \'</td>\';
echo \'<td>\';
//$termina=$row[\'termina\']-$row[\'inicia\'];
$campo = substr ($buffer, $row[\'inicia\'],$row[\'cuantos\']); // devuelve "bcd"
// $campo = substr ($buffer, 2,1); // devuelve "bcd"
echo $campo.\'<br>\';
echo \'</td>\';
$i++;
}
echo \'</tr>\';
echo \'</table>\';
fclose ($fd);
//Aqui se suben todos lo Registros
if($enviar==\'Enviar\')
{
set_time_limit (0);
$fd = fopen ("prueba.tx", "r");
$sql=\'SELECT * FROM campos\';
$result=mysql_query($sql,$conexion);
while (!feof($fd))
{
$buffer = fgets($fd, 4096);
//se lee la longitud de cada campo
mysql_data_seek($result,0);
$sql_insert="INSERT INTO `importaciones`
VALUES (";
while ($row=mysql_fetch_array($result))
{
if($row[\'campo\']==\'campo1\')
{
$campo="";//Aqui se debe llamar la funcion que toma el consecutivo
}else
{
$campo = substr ($buffer, $row[\'inicia\'], $row[\'cuantos\']); // devuelve "bcd"
//$campo = substr ($buffer, 1, 2); // devuelve "bcd"
}
$sql_insert .="\'". $campo."\',";
//echo $campo.\'<br>\';
//echo $resto.\'<br>\';
}//fin del while
$longitud=strlen ($sql_insert);
$sql_insert=substr ($sql_insert,0, $longitud-1);
$sql_insert .=")";
// echo $sql_insert.\'<br>\';
if (!$query = mysql_query($sql_insert,$conexion))
{
$mensaje= \'Problemas al intentar subir el archivo! \';
}
else
{
}
}
echo \'MIGACION DE ARCHIVO TERMINADA\';
fclose ($fd);
}
?>
<p>Â </p><form name="form1" method="post" action="file:///C|/AppServ/www/dian/archivo.php">
<input name="enviar" type="submit" id="enviar" value="Enviar">
</form>
<p>Para subir todos los registros utilice el botòn Enviar</p>
PARA QUE NO DIGAN QUE SOLO PIDO AYUDA HAY ESTA EL CODIGO LO HAGO PORQUE MUCHAS VECES ME HA SERVIDO LO QUE PUBLICAN LOS DEMAS.
EL SCRIP FUNCIONA DE MARAVILLA, EL LIO ES QUE PARA QUE ESTO PASE EL ARCHIVO DEBE ESTAR EN EL SERVIDOR EN LA MISMA UBICACION DEL SCRIP.
Y LO QUE NECESITO ES QUE LA LECTURA SE HAGA CON EL ARCHIVO EN EL CLIENTE SIN PASARLO AL SERVIDOR.
SI ALGUIEN ME PUEDE ASESORAR DE COMO SE HACE SE LO AGRADEZCO.
<tr>
<td>MIGRACION DE ARCHIVO A BASE DE DATOS</td>
<td>Â </td>
</tr>
<tr>
<td>Previsualizaciòn de Resultados</td>
<td>Â </td>
</tr>
</table>
<?php
//include("librerias/conexion.php");
//$conexion=conexionBD() ;
//pREVISUALIZACION ANTES DE COMENZAR TODA LA INSERCION
$fd = fopen ("prueba.txt", "r");
$buffer = fgets($fd,100);
//se lee la longitud de cada campo
$sql=\'SELECT * FROM campos \';
$result=mysql_query($sql,$conexion);
echo \'<table width="75%" border="1">\';
echo \'<tr>\';
$i=1;
echo $buffer.\'<br>\';
while ($row=mysql_fetch_array($result))
{
echo \'<td>\';
echo \'[\'.$i.\']\';
echo \'</td>\';
echo \'<td>\';
//$termina=$row[\'termina\']-$row[\'inicia\'];
$campo = substr ($buffer, $row[\'inicia\'],$row[\'cuantos\']); // devuelve "bcd"
// $campo = substr ($buffer, 2,1); // devuelve "bcd"
echo $campo.\'<br>\';
echo \'</td>\';
$i++;
}
echo \'</tr>\';
echo \'</table>\';
fclose ($fd);
//Aqui se suben todos lo Registros
if($enviar==\'Enviar\')
{
set_time_limit (0);
$fd = fopen ("prueba.tx", "r");
$sql=\'SELECT * FROM campos\';
$result=mysql_query($sql,$conexion);
while (!feof($fd))
{
$buffer = fgets($fd, 4096);
//se lee la longitud de cada campo
mysql_data_seek($result,0);
$sql_insert="INSERT INTO `importaciones`
VALUES (";
while ($row=mysql_fetch_array($result))
{
if($row[\'campo\']==\'campo1\')
{
$campo="";//Aqui se debe llamar la funcion que toma el consecutivo
}else
{
$campo = substr ($buffer, $row[\'inicia\'], $row[\'cuantos\']); // devuelve "bcd"
//$campo = substr ($buffer, 1, 2); // devuelve "bcd"
}
$sql_insert .="\'". $campo."\',";
//echo $campo.\'<br>\';
//echo $resto.\'<br>\';
}//fin del while
$longitud=strlen ($sql_insert);
$sql_insert=substr ($sql_insert,0, $longitud-1);
$sql_insert .=")";
// echo $sql_insert.\'<br>\';
if (!$query = mysql_query($sql_insert,$conexion))
{
$mensaje= \'Problemas al intentar subir el archivo! \';
}
else
{
}
}
echo \'MIGACION DE ARCHIVO TERMINADA\';
fclose ($fd);
}
?>
<p>Â </p><form name="form1" method="post" action="file:///C|/AppServ/www/dian/archivo.php">
<input name="enviar" type="submit" id="enviar" value="Enviar">
</form>
<p>Para subir todos los registros utilice el botòn Enviar</p>
PARA QUE NO DIGAN QUE SOLO PIDO AYUDA HAY ESTA EL CODIGO LO HAGO PORQUE MUCHAS VECES ME HA SERVIDO LO QUE PUBLICAN LOS DEMAS.
EL SCRIP FUNCIONA DE MARAVILLA, EL LIO ES QUE PARA QUE ESTO PASE EL ARCHIVO DEBE ESTAR EN EL SERVIDOR EN LA MISMA UBICACION DEL SCRIP.
Y LO QUE NECESITO ES QUE LA LECTURA SE HAGA CON EL ARCHIVO EN EL CLIENTE SIN PASARLO AL SERVIDOR.
SI ALGUIEN ME PUEDE ASESORAR DE COMO SE HACE SE LO AGRADEZCO.