Foro de elhacker.net

Programación => PHP => Mensaje iniciado por: raintrooper en 19 Septiembre 2016, 08:28 am



Título: Problema al cargar archivo a una carpeta
Publicado por: raintrooper en 19 Septiembre 2016, 08:28 am
Buenas noches gracias por su ayuda. El problema que tengo es en una pantalla donde cargo un archivo a una carpeta que deseo. El programa si carga el archivo correctamente, pero al momento de ingresar a la pagina me sale este error.

( ! ) Notice: Undefined index: Cargar in C:\wamp\www\Proyecto\convert.php on line 108
Call Stack
#   Time   Memory   Function   Location
1   0.0007   255472   {main}( )   ..\convert.php:0

Pero despues que ya cargue el archivo .txt ya no aparece el error en la pantalla. No se que estoy haciendo mal. El codigo es el siguiente:

<?php
   $path = "txt/";
?>

<form method="POST" enctype="multipart/form-data" action="convert.php">   
<table border="1" width="100%" id="table1">
   <tr>
      <td>
         <p align="center">
         <input type="file" name="Archivo1" id="Archivo"size="80" value="Cargar">
         </p>
      </td>
   </tr>
   <tr>
      <td>
         <p align="center"><input type="submit" value="Cargar" name="Cargar">
      </p>
      <input type="hidden" name="cant" value="1"</td>
   </tr>
  <div id="arch" align="center">
    <table id="archivos" border="1" cellspacing="0" cellpadding="3">
    <tr>
        <td colspan="2" align="center"><b>Archivos cargados</b></td>
    <tr>
<?php

   if ($handle = opendir($path)) {
        while (false !== ($file = readdir($handle))) {
            if ($file<>'.' && $file<>'..') {
               echo "\t<td>$file</td>";
               echo '<input type="hidden" name="archivo" value="' . $file . '"></form></td>';

              }
    }

   
    if ($_POST['Cargar']) {
        for ($i=1;$i<=$_POST['cant'];$i++){
            $target_path = $path;
            $target_path = $target_path . basename($_FILES['Archivo'.$i]['name']);
            if(move_uploaded_file($_FILES['Archivo'.$i]['tmp_name'], $target_path)) {
               
                $file = basename( $_FILES['Archivo'.$i]['name']);
                echo "<tr>\r\n";
                echo "\t<td>" . '<font color="blue">' . $file. "</font></td>\r\n";
               
                echo '<input type="hidden" name="archivo" value="' . $file . '"></form></td>' . "\r\n";
                echo "</tr>\r\n";
            }
        }
    }


Gracias por su ayuda.

EL.