Ver Mensaje Individual
  #10 (permalink)  
Antiguo 10/02/2005, 16:52
kepawe
 
Fecha de Ingreso: agosto-2004
Mensajes: 157
Antigüedad: 19 años, 8 meses
Puntos: 5
Hola de nuevo

Te envio el código

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<html>
<head>
<title>Untitled</title>
<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){
// Extraemos solo el nombre del archivo
file2 = file2.toString().replace(/\.mp3/i,"")
if((/["']|\.{1,}/i).test(file2)){
msg+="No se permiten comillas simples o doble, puntos,"+
"\ en el nombre del archivo.\t\n"
}
if(!(/^.+-.+-\(\d{1,2}\)-.+$/i).test(file2)){
msg+= "El nombre del formato debe tener el siguiente formato.\t\n" +
"Grupo-Disco-(10)-Cancion.mp3"
}
}
else msg+="Solo son validos los archivos con la extension mp3.\t\n"

//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>
<form method="POST" action="uploader.php?action=upload" enctype="multipart/form-data">
<input type="text" size="30" name="field_email" value="[email protected]"></p>
<input type="hidden" name="MAX_FILE_SIZE" value="">
<input type="file" size="30" name="file1" onchange="check_file(this.form)"/></p>
<input class="checktype" type="checkbox" name="field_copy" value="Yes">
<input type ="button" name="field_submit" value="Subir fichero(s)" onclick ="send_form(this.form)">
</form>

</body>
</html>

Saludos