Ver Mensaje Individual
  #6 (permalink)  
Antiguo 02/09/2009, 16:40
Avatar de Superlinux
Superlinux
 
Fecha de Ingreso: octubre-2005
Ubicación: Colombia
Mensajes: 662
Antigüedad: 21 años
Puntos: 1
Pregunta Respuesta: mantener las propiedades de mi input type="file"

este es el archivo validar

Código PHP:
<script type="text/javascript">
function 
actuar(peso, anchura, altura)    {
    
this.peso.value = peso;
    
this.ancho.value = anchura;
    
this.alto.value = altura;
}

function 
ini()    {
    
document.forms.form.actualizar = actuar;
    
window.frames.ver.location.href = "previsor.php";
    
document.forms.form.actualizar(0, 0, 0);
}

function 
validar(f)    {
    
enviar = /.(jpg)$/i.test(f.imgadjunta.value);
    if (!
enviar)    alert("ERROR: Debe seleccionar primero una imagen si lo que desea es subir o actualizar la información...");
    return 
enviar;
}

function 
limpiar()    {
    
document.forms.form.actualizar(0, 0, 0);
    
f = document.getElementById("imgadjunta");
    
nuevoFile = document.createElement("input");
    
nuevoFile.id = f.id;
    
nuevoFile.type = "file";
    
nuevoFile.name = "imgadjunta";
    
nuevoFile.value = "";
    
nuevoFile.onchange = f.onchange;
    
nodoPadre = f.parentNode;
    
nodoSiguiente = f.nextSibling;
    
nodoPadre.removeChild(f);
    (
nodoSiguiente == null) ? nodoPadre.appendChild(nuevoFile):
        
nodoPadre.insertBefore(nuevoFile, nodoSiguiente);
}

function 
checkear(f)    {
    function 
no_prever() {
        
alert("ERROR: El archivo seleccionado no es valido... el formato correcto debe ser *.JPG");
        
limpiar();
    }
    function 
prever() {
        var 
campos = new Array("maxpeso", "maxalto", "maxancho");
        for (
i = 0, total = campos.length; i < total; i ++)
            
f.form[campos[i]].disabled = false;
            
actionActual = f.form.action;
            
targetActual = f.form.target;
            
f.form.action = "previsor.php";
            
f.form.target = "ver";
            
f.form.submit();
        for (
i = 0, total = campos.length; i < total; i ++)
            
f.form[campos[i]].disabled = true;
            
f.form.action = actionActual;
            
f.form.target = targetActual;
    }

    (/.(
jpg)$/i.test(f.value)) ? prever() : no_prever();
}

function 
datosImagen(peso, ancho, alto, error)    {
    function 
mostrar_error()    {
        
enviar = false;                    
        
mensaje = "Ha habido un error (error nº " + error + "):";
        if (
error % 2 == 1) // tipo incorrecto
            
mensaje += "\nERROR: El archivo seleccionado no es valido... el formato correcto debe ser *.JPG";
        
error = parseInt(error / 2);
        if (
error % 2 == 1) // excede en peso
            
mensaje += "\nLa imagen pesa "+ peso +", superando el tamaño maximo permitido de 200.000 bytes o 200 KB ";
        
error = parseInt(error / 2);
        if (
error % 2 == 1) // excede en anchura
            
mensaje += "\nLa imagen tiene en anchura "+ ancho + " pixeles, excediendo la maxima permitida de 437";
        
error = parseInt(error / 2);
        if (
error % 2 == 1) // excede en altura
            
mensaje += "\nLa imagen tiene en altura "+ alto + " pixeles, excediendo la maxima permitida de 318";
        
error = parseInt(error / 2);
        
alert (mensaje);
        
limpiar();
    }
    if (
error == 0)
        
document.forms.form.actualizar(peso, ancho, alto);
    else
        
mostrar_error();
}
</script> 
mmmmm
__________________
"La vida sigue su curso, tú toma parte de ella."