├── README.md
├── downloads
└── notice.msg
├── uploads
└── notice.msg
├── LICENSE
├── api
└── compress.zip.php
├── index.html
└── src
├── compress.js
└── compress.css
/README.md:
--------------------------------------------------------------------------------
1 | # zipper
2 | zipper convert multiple files to zip file using languages HTML, css, Javascript && php
3 |
--------------------------------------------------------------------------------
/downloads/notice.msg:
--------------------------------------------------------------------------------
1 | # download folder in store converted zip file
2 |
3 | # when user download zip file click on download button
4 | so we are delete the zip file so user download
--------------------------------------------------------------------------------
/uploads/notice.msg:
--------------------------------------------------------------------------------
1 | # uploads folder in uploaded media any files
2 |
3 | # zip converting process in first step store files
4 | while converted after zip file
5 |
6 | when zip file converted succesfully so i delete
7 | this all files beacuse no be full web memeory and
8 | height load in my website
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2022 Modassir
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/api/compress.zip.php:
--------------------------------------------------------------------------------
1 | $value ) {
10 | if ( !empty( $value ) ) return false;
11 | }
12 | return true;
13 | }
14 |
15 | $rzipname = "/^[a-zA-Z0-9\-\._ ]+$/";
16 |
17 | if ( empty( $zipname ) ) {
18 | die( json_encode( array("error"=>"zipname is required. please enter your zipname?") ) );
19 | }
20 | else if ( !preg_match( $rzipname, $zipname ) ) {
21 | die( json_encode( array("error"=>"Invalid zipname you cannot use '".$zipname."' zipname") ) );
22 | }
23 |
24 | if ( isEmptyFile( $files ) ) {
25 | die( json_encode( array("error"=>"We cannot create zip. plase select your file") ) );
26 | }
27 |
28 | $dir = "../downloads/";
29 | $zipSetup = $dir.$zipname.".zip";
30 | $status = "error";
31 |
32 | $zip = new ZipArchive();
33 | $zip->open( $zipSetup, ZipArchive::CREATE);
34 | foreach( $files["name"] as $index=>$value ) {
35 | // get file tmp_name
36 | $tmp_name = $files["tmp_name"][ $index ];
37 |
38 | if ( move_uploaded_file( $tmp_name, "../uploads/".$value ) ) {
39 | $zip->addFile( "../uploads/".$value );
40 | $status = "success";
41 | }
42 | }
43 | $zip->close();
44 |
45 | // now delete/remove before uploaded files
46 | foreach( $files["name"] as $key=>$filename ) {
47 | if ( file_exists( "../uploads/".$filename ) ) {
48 | unlink( "../uploads/".$filename );
49 | }
50 | }
51 |
52 | function sizeFormat( $size ) {
53 | $sizes = array( " Bytes", " KB", " MB", " GB" );
54 | if ( $size === 0 ) {
55 | return ('n/a');
56 | } else {
57 | return ( round( $size / pow( 1024, ( $i = floor( log( $size, 1024 ) ) ) ), 2 ) . $sizes[ $i ] );
58 | }
59 | }
60 |
61 | $formatSize = sizeFormat( filesize( $zipSetup ) );
62 | die( json_encode( array($status=>"'".$zipname."' converted zip successfully!", "zipname"=>$zipname, "size"=>$formatSize) ) );
63 | }
64 |
65 | if ( isset( $_GET["rmv"] ) ) {
66 | $rmv_file_setup = "../downloads/".$_GET["rmv"].".zip";
67 | if ( file_exists( $rmv_file_setup ) ) {
68 | unlink( $rmv_file_setup );
69 | }
70 | die("success"); // die success status
71 | }
72 | ?>
--------------------------------------------------------------------------------
/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | Convert files to zip
8 |
9 |
10 |
11 |