Hello, I ran into this problem in an application I am creating to compare files. I am new to this and, after seeing several websites specialized in it and changing the code several times, I cannot get it to show me the two files to be able to follow the programming. I detail how I have defined everything:
tratar_csv.php
<pre><!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Descarga ficheros CSV</title>
</head>
<body>
<div class="container">
<DIV id="PANEL_0" class="panel panel-primary text-justify">
<DIV class="panel-heading">
<H3 class="panel-title">Fichero a trabajar</H3>
</DIV>
<DIV class="panel-body">
<FORM action="ficheros_permitidos.php" method="POST" enctype="multipart/form-data">
<DIV class="form-group">
<label for="origen" role="button">Fichero CSV:</label>
<INPUT id="origen" type="file" name="origen" class="form_control" />
</DIV>
<input type="hidden" name="MAX_FILE_SIZE" value="50000000">
<input type="submit" name="continuar" value="Fichero de origen">
<input type="submit" name="reset" value="Reiniciar">
</FORM>
</DIV>
</DIV>
</div>
</body>
</html>
</doctype>
ficheros_permitidos.php
<pre><?php
if (isset($_POST['continuar'])) {
$nombreFichero = $_FILES['origen']['name'];
$tipoFichero=pathinfo($nombreFichero,PATHINFO_EXTENSION);
switch($tipoFichero) {
case 'csv':
include_once('procesa.php');
break;
case 'xls':
include_once('procesa.php');
break;
case 'txt':
include_once('procesa.php');
break;
default:
include_once('error.php');
break;
}
}
if (isset($_POST['reset'])) {
header('location:tratar_csv.php');
}
?>
<script type="text/javascript">
function Redirect()
{
window.location="tratar_csv.php";
}
setTimeout('Redirect()', 30000);
</script>
procesa.php
<pre><!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Ficheros a evaluar</title>
</head>
<body>
<div class="container">
<DIV id="PANEL_0" class="panel panel-primary text-justify">
<DIV class="panel-heading">
<H3 class="panel-title">Múltiples ficheros a evaluar</H3>
</DIV>
<DIV class="panel-body">
<FORM action="ficheros_permitidos_multiples.php" method="POST" enctype="multipart/form-data">
<DIV class="form-group">
<label for="archivos_multiples" role="button">Archivo a comparar:</label>
<INPUT id="archivos_multiples" type="file" name="archivo" class="form-control" />
</DIV>
<input type="submit" name="comparar" value="Comparar ficheros">
<input type="submit" name="reset" value="Reiniciar">
</FORM>
</DIV>
</DIV>
</div>
</body>
</html>
</doctype>
ficheros_permitidos_multiples.php
<?php
if (isset($_POST['comparar'])) {
$nombreArchivo = $_FILES['archivo']['name'];
$tipoArchivo=pathinfo($nombreArchivo,PATHINFO_EXTENSION);
switch($tipoArchivo) {
case 'csv':
include('buscar_y_comparar.php');
break;
case 'xls':
include('buscar_y_comparar.php');
break;
case 'txt':
include('buscar_y_comparar.php');
break;
default:
include('error.php');
break;
}
}
if (isset($_POST['reset'])) {
header('location:procesa.php');
}
?>
<script type="text/javascript">
function Redirect()
{
window.location="procesa.php";
}
setTimeout('Redirect()', 30000);
</script>
buscar_y_comparar.php
<?php
$nombreFichero=($_FILES["origen"]["name"]);
$nombreArchivo=($_FILES["archivo"]["name"]);
echo("Empezar la búsqueda y comparación entre archivos");
echo("<br>");
echo($nombreFichero);
echo("<br>");
echo($nombreArchivo);
?>
The result I have achieved from all this is the following:
Notice: Undefined index: origen in C:\xampp\htdocs\buscar_y_comparar.php on line 6
Notice: Trying to access array offset on value of type null in C:\xampp\htdocs\buscar_y_comparar.php on line 6
Empezar la búsqueda y comparación entre archivos
Sanitario.csv
Thanks in advance for your help
What I have tried:
if(isset($_GET[$tipoArchivo])) {
$fichero=($_FILES['origen']);
$nombreFichero=array();
$nombreFichero=($_FILES["origen"]["name"]);
$nombreArchivo=($_FILES["archivo"]["name"]);