Micro Niche Builder
Closed Thread
Results 1 to 7 of 7

Thread: Making zip at run time using php

  1. #1

    Default Making zip at run time using php

    I want to make zip file when someone uploads an image on my site. I want to make it zip and then store it to the server.

    Thank you for your help


  2. SEO Software

  3. #2

    Default

    try these functions if they help.
    zip_open(string filename)
    zip_read(resource zip)
    I wish to change the world, but they don`t provide me the source. HACK - 'R'

    PHP 5 AJAX

  4. #3

    Question

    Quote Originally Posted by rohitanu View Post
    try these functions if they help.
    zip_open(string filename)
    zip_read(resource zip)
    i got the function which you have posted....
    but confused that where i have to write this function...???
    is there any specific task for it or just like regular one...??

  5. #4
    Master Apprentice Handsome is on a distinguished road Handsome's Avatar
    Join Date
    Feb 2009
    Location
    Multan/Pakistan
    Posts
    2,040
    Thanks
    317
    Thanked 134 Times in 107 Posts
    Blog Entries
    5

    Default

    There is every easy solution for it

    just use 4images gallery coz there are lot of option there including zip file too

  6. #5

    Default

    There is a zip library in php you can use that library to make zip at run time.

  7. #6

    Default

    It will creates a compressed zip file


    function create_zip($files = array(),$destination = '',$overwrite = false) {
    //if the zip file already exists and overwrite is false, return false
    if(file_exists($destination) && !$overwrite) { return false; }
    //vars
    $valid_files = array();
    //if files were passed in...
    if(is_array($files)) {
    //cycle through each file
    foreach($files as $file) {
    //make sure the file exists
    if(file_exists($file)) {
    $valid_files[] = $file;
    }
    }
    }
    //if we have good files...
    if(count($valid_files)) {
    //create the archive
    $zip = new ZipArchive();
    if($zip->open($destination,$overwrite ? ZIPARCHIVE::OVERWRITE : ZIPARCHIVE::CREATE) !== true) {
    return false;
    }
    //add the files
    foreach($valid_files as $file) {
    $zip->addFile($file,$file);
    }
    //debug
    //echo 'The zip archive contains ',$zip->numFiles,' files with a status of ',$zip->status;

    //close the zip -- done!
    $zip->close();

    //check to make sure the file exists
    return file_exists($destination);
    }
    else
    {
    return false;
    }
    }

  8. #7

    Default

    you should have special library called ziplib to make zip usign php. Check whether your host have installed it on yoru server or not.

Closed Thread

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts