anun1

sábado, 5 de marzo de 2022

Abrir, Agregar y Extraer archivos zip en javascript y html Codigo

 hola amigos aqui les dejo un codigo en javascript y HTML que sirbe para ver los archivos que estan dentro de un zip, asi como agregar y tambien extraerlos


 

Codigo


<html>

<head>

<title>ziper</title>

</head>

<body bgcolor="black">

<br><br><br><br>

<marquee><label style="color:white;">Zipeador By Flamer</label></marquee>

<br><br><br>

<center>

<label style="color:white;">Archivo ZIP:</label>

<input type="file" id="ruta" size="100" style="text-align:center;background:black;color:white;" id="zip"><br>

<label style="color:white;">Agregar ZIP:</label>

<input type="file" id="add" size="100" style="text-align:center;background:black;color:white;" id="zip" disabled><br><br>

<textarea id="log" rows="10" style="width:300;background:black;color:white;"></textarea>

<br><br>

<input type="button" value="Ver Archivos Del Zip" onclick="Abrir(1)">

<input type="button" value="Extraer Archivos Del Zip" onclick="Abrir(2)"><input type="button" value="Agregar Archivos Al Zip" onclick="agrega()"></center><script>

var app,fso

app   = new ActiveXObject("shell.application")

fso=new ActiveXObject("scripting.filesystemobject")

function agrega()

{

   var archi,f,z,file

   archi = document.getElementById("ruta").value

   f=fso.getfile(archi)

   z=f.type.indexOf("zip")

   

   if(fso.fileexists(archi) && z==-1)

   {

      document.getElementById("add").disabled=false

      document.getElementById("add").click() 

  file=document.getElementById("add").value

  app.namespace(archi).copyhere(file)

  alert("Archivo comprimido con exito")

   }

   else

   {

      alert("Archivo no existente o archivo incorrecto")

   }

}

function Abrir(op)

{

   var files,f,archi 

   archi = document.getElementById("ruta").value

   if(archi!="")

   {

      if(archi.indexOf(".zip")!=-1)

  {

          if(op==1)

  {

     ver(archi)

  }

  else if(op==2)

  {

     Extraction(archi)

  }

  }

      else

      {

     alert("El archivo seleccionado no es un Zip")

   }   

   }

   else

   {

      alert("Campo file Vacio")

   }   

}

function ver(archi)

{

   var f,files 

   files=app.namespace(archi).items()

   for(f=0;f<files.count;f++)

   {

      document.getElementById("log").value+=files.item(f) + "\n"

   }

}

function Extraction(archi)

{

   var nom,carpeta     

   

   nom=fso.getfile(archi)

   carpeta=nom.name.replace(".zip","")

   if(!fso.folderexists(carpeta))

   {

      fso.createfolder(carpeta)

  alert("carpeta "+ carpeta + " creada con exito")

   }

   app.namespace(carpeta).copyhere(app.namespace(archi).Items()) 

}

</script>

</body>

</html>


bueno saludos y espero les guste