
JoseCuevas
Iota
Verificación en dos pasos activada
Verificado por Whatsapp
Hola betas buenas noches, alguno de ustedes me podría asesorar respecto a cómo leer un archivo excell en php? Necesito leerlo linea por linea ya la vez ir insertando el contenido en una base de datos, hasta el momento tengo lo que sería el script para subir correctamente el archivo:
Otro detalle, resulta que no sé cómo leer que columna del excell es y qué valor es el que tiene según la fila... nunca había manejado lectura de archivos excell, ¿Podrían ayudarme?
Muchísimas gracias!
PHP:
<?php
$target_dir = "uploads/";
$target_file = $target_dir . basename($_FILES["fileToUpload"]["name"]);
$uploadOk = 1;
$imageFileType = strtolower(pathinfo($target_file,PATHINFO_EXTENSION));
// Check if image file is a actual image or fake image
if(isset($_POST["submit"])) {
$check = getimagesize($_FILES["fileToUpload"]["tmp_name"]);
if($check !== false) {
echo "File is an image - " . $check["mime"] . ".";
$uploadOk = 1;
} else {
echo "File is not an image.";
$uploadOk = 0;
}
}
// Check if $uploadOk is set to 0 by an error
if ($uploadOk == 0) {
echo "Sorry, your file was not uploaded.";
// if everything is ok, try to upload file
} else {
if (move_uploaded_file($_FILES["fileToUpload"]["tmp_name"], $target_file)) {
//Aquí es donde debo leer el archivo linea por linea e ir insertando la información
//echo "The file ". basename( $_FILES["fileToUpload"]["name"]). " has been uploaded.";
} else {
echo "Sorry, there was an error uploading your file.";
}
}
?>
Otro detalle, resulta que no sé cómo leer que columna del excell es y qué valor es el que tiene según la fila... nunca había manejado lectura de archivos excell, ¿Podrían ayudarme?
Muchísimas gracias!