Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE html>
- <html lang="pt-br">
- <head>
- <meta charset="UTF-8">
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
- <meta name="author" content="Mizuno">
- <title>Compactador de Arquivos</title>
- <script src="https://cdnjs.cloudflare.com/ajax/libs/jszip/3.1.5/jszip.min.js"></script>
- <script src="https://cdnjs.cloudflare.com/ajax/libs/FileSaver.js/2.0.5/FileSaver.min.js"></script>
- <style>
- body {
- font-family: Arial, sans-serif;
- max-width: 600px;
- margin: 20px auto;
- text-align: center;
- }
- input {
- margin: 10px 0;
- }
- button {
- padding: 10px;
- background-color: #4CAF50;
- color: white;
- border: none;
- border-radius: 4px;
- cursor: pointer;
- }
- button:hover {
- background-color: #45a049;
- }
- </style>
- </head>
- <body>
- <h1>Compactador de Arquivos</h1>
- <input type="file" id="fileInput" multiple>
- <button onclick="compactar()">Compactar</button>
- <script>
- function compactar() {
- var inputElement = document.getElementById('fileInput');
- var files = inputElement.files;
- if (files.length > 0) {
- var zip = new JSZip();
- for (var i = 0; i < files.length; i++) {
- var file = files[i];
- zip.file(file.name, file);
- }
- var currentDate = new Date();
- var formattedDate = currentDate.toISOString().replace(/:/g, "-").split(".")[0];
- var zipFileName = "arquivo_" + formattedDate + ".zip";
- zip.generateAsync({ type: "blob" })
- .then(function (content) {
- saveAs(content, zipFileName);
- });
- } else {
- alert("Por favor, escolha pelo menos um arquivo.");
- }
- }
- </script>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement