Ver Mensaje Individual
  #1 (permalink)  
Antiguo 26/05/2011, 07:04
georgiy_84
 
Fecha de Ingreso: marzo-2010
Ubicación: Buenos Aires
Mensajes: 25
Antigüedad: 15 años
Puntos: 2
Pregunta Problema con $_FILES

Hola Amigos. Yo ayer pregunte en la sección javascript si me pueden ayudar pero nadie me respondió, tema es así tengo un script en javascript que te permite agregar campos para subir archivos (type="file") este script anda lo mas bien lo que no puedo es levantar archivo en código de PHP para guardar en directorio y el nombre del archivo en la BD, códigos son siguientes:

Código HTML:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>ttt</title>
<script type="text/javascript">
<!--

function addEvent()
{
var ni = document.getElementById('myDiv');
var numi = document.getElementById('theValue');
var num = (document.getElementById("theValue").value -1)+ 2;
numi.value = num;
var divIdName = "my"+num+"Div";
var newdiv = document.createElement('div');
newdiv.setAttribute("id",divIdName);
newdiv.innerHTML = "File: <input type='file' id='myfile[] name='myfile[]'> <a href=\"javascript:;\" onclick=\"removeEvent(\'"+divIdName+"\')\">Remove</a>";
ni.appendChild(newdiv);
}

function removeEvent(divNum)
{
var d = document.getElementById('myDiv');
var olddiv = document.getElementById(divNum);
d.removeChild(olddiv);
var numi = document.getElementById('theValue');
numi.value = numi.value - 1;
}


function validate ()
{
//alert ('hi');
//var ni = document.getElementById('myfile');
//alert(ni);
return true;
}

//-->
</script>
</head>

<body>
<form method='post' action='upload.php' name='form1' onsubmit='return validate()'>
<input type="hidden" value="0" id="theValue" name='theValue'/>
<p><a href="javascript:;" onclick="addEvent();">agregar campo para archivo</a></p>
<div id="myDiv"> <script type="text/javascript">addEvent(); </script></div>
<input type='submit' name='submit'>
</form>
</body>
</html> 
y codigo de PHP :

Código PHP:
<?php
    
echo $_FILES['myfile']['name'].' Prueba1<br>';
    echo 
$_REQUEST['myfile'].' Prueba2<br>';
    
print_r ($_FILES['myfile']['name'].' Prueba3<br>');
?>
Bueno y no me toma el archivo no sé como tomarlo porque cuando uso campos comunes tipo: <input type='file' id='myfileB' name='myfileB'> sin "[]" me anda bien y cuando quiero mandar como array no anda si alguien me puede ayudar lo agradezco mucho.