Ver Mensaje Individual
  #15 (permalink)  
Antiguo 15/02/2005, 12:02
apañero
 
Fecha de Ingreso: abril-2004
Mensajes: 310
Antigüedad: 20 años
Puntos: 0
ok te pongo la pagina entera. La canción con la extensión tiene que ser Grupo-Disco-(XX)-Cancion.mp3 sólo un .mp3

Bueno ahi te lo dejo:
Código:
<html>
<head>

<script language=JavaScript type=text/javascript>
<!--
function reset_file(current_form){
var temp_array = new Array()
for(var ctr = 0 ; ctr < current_form.length; ctr++){
if(current_form[ctr].type == "text") temp_array[ctr] = current_form[ctr].value
else if(current_form[ctr].type == "checkbox") temp_array[ctr] = current_form[ctr].checked
else temp_array[ctr] = "empty"
}
current_form.reset()
for(var ctr = 0 ; ctr < current_form.length; ctr++){
if(current_form[ctr].type == "text") current_form[ctr].value = temp_array[ctr]
else if(current_form[ctr].type == "checkbox")current_form[ctr].checked = temp_array[ctr]
}

}


function check_file(current_form){
// si esta vacio permitimos enviar el formulario
var msg = ""
//alert(current_form.file1.value)
if(current_form.file1.value.search(/\S/g) == -1){
alert("Mensaje si el campo esta vacio");
return false
}
// extraemos el nombre del archivo y la extension
var file2 = current_form.file1.value.match(/[^\/\\]+\.mp3$/i)
// la extension de archivo son validas
if(file2 == null) msg+="Solo son validos los archivos con la extension mp3.\t\n"
if(file2 != null){
// Extraemos solo el nombre del archivo
file2 = file2.toString()
var pts = (/\.mp3\.mp3$/i).test(file2) ? false : true
file2 = !pts ? file2.replace(/\.mp3\.mp3$/i,""):file2.replace(/\.mp3$/i,"")

if((/["']|\./i).test(file2)){
msg+="No se permiten comillas simples o doble,"+
" ni puntos salvo el de la extensión.\t\n"
}
if(!(/^.+-.+-\(\d\)-.+/i).test(file2)||pts){
msg+= "El nombre del archivo debe tener el siguiente formato:\t\n" +
"Grupo-Disco-(10)-Cancion.mp3"
}
}


//Si el mensaje no esta vacio
if(msg!=""){
alert(msg)
reset_file(current_form)
return false
}
// esta todo bien
else return true


}


function send_form(current_form){
for(var ctr = 0; ctr < current_form.length; ctr++){
if(current_form[ctr].name == "file1"){
if(!check_file(current_form)) return false
}

}
// enviamos el formulario
current_form.submit()
}
//-->
</script>


</head>

<body>



<p align="center"></p>
<p align="center">[Tamaño Máximo de archivo: 2MB]</p><p align="center">[Archivos permitidos: &nbsp;.mp3
]</p>

<div align="center"><center>
<form method="POST" action="uploader.php?action=upload" enctype="multipart/form-data">
<table border="0" width="600">
    <tr>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
    </tr>
    <tr>
        <td width="35%"><p align="right"><b>E-Mail: </b>
        </p>
        </td>
        <td width="65%"><p align="left"><input type="text" size="30" name="field_email" value="[email protected]"></p>
        </td>
    </tr>    
        
        <tr>
        <td width="35%"><p align="right"><b>Fichero a enviar: </b></p>
        </td>
        <td width="65%"><p align="left"><input type="hidden" name="MAX_FILE_SIZE" value="">
        <input type="file" size="30" name="file1" onchange="check_file(this.form)"/></p>
        </td>
    </tr>


    

    <tr>
        <td width="35%">&nbsp;</td>
        <td width="65%">&nbsp;</td>
    </tr>
    <tr>
        <td align="center" colspan="2" width="100%"><input class="checktype" type="checkbox" name="field_copy" value="Yes">Deseo recibir confirmación del envío</td>
    </tr>
    <tr>
        <td width="35%">&nbsp;</td>
        <td width="65%">&nbsp;</td>
    </tr>
    <tr>
        <td align="center" colspan="2" width="100%"><input type="submit" name="field_submit" value="Subir fichero(s)" onclick ="send_form(this.form)"></td>
    </tr>
    <tr>
        <td width="35%">&nbsp;</td>
        <td width="65%">&nbsp;</td>
    </tr>
</table>
</form>
</center></div><p align="center"><font size="1" face="verdana"></font></p>


</body>
</html>