anun1

sábado, 1 de mayo de 2021

Comprimir Archivos En Formato Zip Con Javascript y Html

Este tema es similar al que escribí tiempo atrás este

https://elblogdeflamer.blogspot.com/2019/08/codigo-crear-un-archivo-zip-usando.html

pero ahora será un poco mas grafico para eso solo ocuparemos en el bloc de notas y el siguiente código

<html>
<head><title>Compresor de archivos Zip</title>
</head>
<body>
<marquee>Compresor de archivos Zip</marquee>
<center>
<br><br><br><br><br>
Archivo a Comprimir:<input type="file" size="70" id="ruta1"><br><br>
Nombre Del archivo Comprimido:<input type="text" id="ruta2" style="text-align:center;"><br><br>
<input type="button" value="COMPRIMIR" onclick="compress()">
<script>
function compress()
{
   var fso = new ActiveXObject("Scripting.filesystemobject");
   var app = new ActiveXObject("shell.application");
   var path1 = document.getElementById("ruta1").value;
   var path2 = document.getElementById("ruta2").value;

   if(path1=="" || path2=="")
   {
      alert("Se Encontraron campos vacios");
   }
   else
   {
       path2+=".zip";
       var bin = "PK" + String.fromCharCode(5) + String.fromCharCode(6) + Array(19).join(String.fromCharCode(0)); 
       var file = fso.createtextfile(path2);
	   
       file.write(bin);
       file.close();
       app.namespace(path2).copyhere(path1);
       alert("Listo Archivo Comprimido Con Exito");

   }
}
</script>
</center>
</body>
</html>

después le ponemos cualquier nombre y lo aguardamos con la extensión .hta

nos quedara un formulario como este




bueno saludos Flamer

 

No hay comentarios.:

Publicar un comentario