Ver Mensaje Individual
  #6 (permalink)  
Antiguo 30/03/2008, 11:34
brainstorm
 
Fecha de Ingreso: septiembre-2005
Ubicación: España
Mensajes: 78
Antigüedad: 18 años, 8 meses
Puntos: 0
Re: añadir name="userfile[]" a script de http://the-stickman.com/ de upload multiple

Hola caricatos ehh... te estoy agradecido pero va a ser que no va.

Te cuento...
Dejando el archivo JavaScript externo tal cual sin tocar.

El Html dejandolo asi no añade las famosas etiquetas name="userfile[]" a los campos que genera pero los ocualta los nuevos campos y da la sensacion de estar usando todo el rato el mismo input
Código PHP:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<
html>
<
head>
<
title>
    
http://www.caricatos.net/probador
</title>
<
script language="javascript" src="multifile.js"></script>
</head>
<body>

<form onsubmit="for (i = 0; i < this['userfile[]'].length; i++) this['userfile[]'][i].disabled = false" action="javascript: alert('Ok')" >

<input id="my_file_element" type="file" onchange="x=this.cloneNode(true); x['value'] = ''; this.parentNode.insertBefore(x, this.nextSibling); this.disabled = true;" name="userfile[]" />
<div id="files_list"></div>
<button type="submit"> enviar </button>

</form>

<script> 
    <!-- Create an instance of the multiSelector class, pass it the output target and the max number of files --> 
    var multi_selector = new MultiSelector( document.getElementById( 'files_list' ), 3 ); 
    <!-- Pass in the file element --> 
    multi_selector.addElement( document.getElementById( 'my_file_element' ) ); 
</script>

</body>
</html> 
En cambio si lo dejo asi funciona a medias pues se añaden los name="userfile[]" a cada input pero no se ocultan en pantalla cada uno que se agrega y no se produce el efecto de estar usando el mismo input todo el rato (tipo GMAIL).

Código PHP:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<
html>
<
head>
<
title>
    
http://www.caricatos.net/probador
</title>
<
script language="javascript" src="multifile.js"></script>
</head>
<body>

<form onsubmit="for (i = 0; i < this['userfile[]'].length; i++) this['userfile[]'][i].disabled = false" action="javascript: alert('Ok')" >

<input id="my_file_element" type="file" onchange="x=this.cloneNode(true); x['value'] = ''; this.parentNode.insertBefore(x, this.nextSibling); this.disabled = true;" name="userfile[]" />
<div id="files_list"></div>
<button type="submit"> enviar </button>

</form>
</body>
</html>