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: 18 años, 7 meses
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(pesoanchuraaltura)    {
    
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(000);
}

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(000);
    
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(nuevoFilenodoSiguiente);
}

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 (
0total campos.lengthtotal++)
            
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 (
0total campos.lengthtotal++)
            
f.form[campos[i]].disabled true;
            
f.form.action actionActual;
            
f.form.target targetActual;
    }

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

function 
datosImagen(pesoanchoaltoerror)    {
    function 
mostrar_error()    {
        
enviar false;                    
        
mensaje "Ha habido un error (error nº " error "):";
        if (
error == 1// tipo incorrecto
            
mensaje += "\nERROR: El archivo seleccionado no es valido... el formato correcto debe ser *.JPG";
        
error parseInt(error 2);
        if (
error == 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 == 1// excede en anchura
            
mensaje += "\nLa imagen tiene en anchura "ancho " pixeles, excediendo la maxima permitida de 437";
        
error parseInt(error 2);
        if (
error == 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(pesoanchoalto);
    else
        
mostrar_error();
}
</script> 
mmmmm
__________________
"La vida sigue su curso, tú toma parte de ella."