SitePoint Sponsor

User Tag List

Results 1 to 18 of 18
  1. #1
    SitePoint Addict
    Join Date
    Oct 2010
    Posts
    207
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Exclamation automatic zip and download?

    is there any way that a folder on my site
    automatic zip and ready to download
    mean for example a folder on my site in which are different files like different songs mp3 files
    i want that i can also give people an option to download all movie songs in a folder
    and show their link
    when the click on link that folder automatic convert in zip and ready to download ?
    i think my ideas is workable ?suggestion plzz how it will exactly work no
    realcoder is online now Report Post Edit/Delete Message Reply With Quote Multi-Quote This Message Quick reply to this message
    realcoder
    View Public Profile
    Send a private message to realcoder
    Find More Posts by realcoder
    Add realcoder to Your Contacts
    Reply

  2. #2
    SitePoint Addict
    Join Date
    Oct 2010
    Posts
    207
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    sorry above post is little wrong my question is only this

    is there any way that a folder on my site
    automatic zip and ready to download
    mean for example a folder on my site in which are different files like different songs mp3 files
    i want that i can also give people an option to download all movie songs in a folder
    and show their link
    when the click on link that folder automatic convert in zip and ready to download ?
    i think my ideas is workable ?suggestion plzz how it will exactly work no

  3. #3
    SitePoint Wizard bronze trophy chris.upjohn's Avatar
    Join Date
    Apr 2010
    Location
    Melbourne, AU
    Posts
    2,197
    Mentioned
    17 Post(s)
    Tagged
    1 Thread(s)
    This is what you need http://www.phpconcept.net/pclzip, they have great documentation and i haven't had any issues with them

  4. #4
    SitePoint Addict
    Join Date
    Oct 2010
    Posts
    207
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    can u little describe how i zip a folder using their class

  5. #5
    SitePoint Wizard bronze trophy chris.upjohn's Avatar
    Join Date
    Apr 2010
    Location
    Melbourne, AU
    Posts
    2,197
    Mentioned
    17 Post(s)
    Tagged
    1 Thread(s)
    It has all the information you need in there documentation, if you have issues understanding it try as much as you can then we can you further.

    http://www.phpconcept.net/pclzip/user-guide

  6. #6
    SitePoint Addict
    Join Date
    Oct 2010
    Posts
    207
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    infect m not familiar with OOP so it's difficult to understand exact i have try it before but don't get much

  7. #7
    SitePoint Addict
    Join Date
    Oct 2010
    Posts
    207
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    i think i got it

    require_once('pclzip.lib.php');
    $archive = new PclZip('archive.zip');
    $v_list = $archive->add('foldername',
    PCLZIP_OPT_REMOVE_PATH, 'dev');

  8. #8
    SitePoint Addict
    Join Date
    Oct 2010
    Posts
    207
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    i thik here is some problem i can't use varibales in values ?why?if yes how

  9. #9
    SitePoint Wizard bronze trophy chris.upjohn's Avatar
    Join Date
    Apr 2010
    Location
    Melbourne, AU
    Posts
    2,197
    Mentioned
    17 Post(s)
    Tagged
    1 Thread(s)
    The method "add" is for when your appending files to an existing zip file, the method you need to use is "create". See if the code below works for you

    PHP Code:
    // Set the directory
    $dir "A Flat";

    $fileList = array();

    if (
    is_dir($dir)){
        if (
    $open opendir($dir)){
            while(
    false !== ($read readdir($open))){
                if (
    $read != '.' && $read != '..'){
                    echo 
    $read." - File Size: ".filesize($dir."/".$read)." bytes<br />";
                    
    $fileList[] = $read;
                }
            }
        } else {
            echo 
    "Unable to open the directory at \"$dir\"";
        }
    } else {
        echo 
    "The directory ( $dir ) is not a valid path!";


    // Make sure the array is at least "1" value
    if (sizeof($fileList) > 0){
        
    // Include the PCLZip class
        
    include_once('pclzip.lib.php');
        
        
    // Create a new instance of the class
        
    $archive = new PclZip('mp3_files.zip');
        
        
    // Build a list of the files
        
    $files implode(', '$fileList);
        
        
    // Add the files to the archive
        
    $v_list $archive->create($files);
        
        
    // Finish up
        
    if ($v_list == 0){
            die(
    "Error : ".$archive->errorInfo(true));
        } else {
            
    header('Location: mp3_files.zip');
        }


  10. #10
    SitePoint Addict
    Join Date
    Oct 2010
    Posts
    207
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    well brother can't i pass it values through variables because i try to do give values through that don't work

  11. #11
    SitePoint Addict
    Join Date
    Oct 2010
    Posts
    207
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    and which code u write that also giving wrong error

    Error : PCLZIP_ERR_MISSING_FILE (-4) : File '01 - Meetha Sa Ishq.mp3' does not exist
    even file is exists

  12. #12
    SitePoint Wizard bronze trophy chris.upjohn's Avatar
    Join Date
    Apr 2010
    Location
    Melbourne, AU
    Posts
    2,197
    Mentioned
    17 Post(s)
    Tagged
    1 Thread(s)
    Thats my fault, in the while loop the appending values should be

    PHP Code:
    $fileList[] = $dir."/".$read

  13. #13
    SitePoint Addict
    Join Date
    Oct 2010
    Posts
    207
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Now this one
    Error : PCLZIP_ERR_MISSING_FILE (-4) : File ' A Flat/02 - Dil Kashi.mp3' does not exist

  14. #14
    SitePoint Addict
    Join Date
    Oct 2010
    Posts
    207
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    well got this problem there was one extra space in explode

  15. #15
    SitePoint Addict
    Join Date
    Oct 2010
    Posts
    207
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    well thanks

  16. #16
    SitePoint Wizard bronze trophy chris.upjohn's Avatar
    Join Date
    Apr 2010
    Location
    Melbourne, AU
    Posts
    2,197
    Mentioned
    17 Post(s)
    Tagged
    1 Thread(s)
    No problem, everything is working alright for you?

  17. #17
    SitePoint Addict
    Join Date
    Oct 2010
    Posts
    207
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    yes

  18. #18
    SitePoint Addict
    Join Date
    Oct 2010
    Posts
    207
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Error : PCLZIP_ERR_READ_OPEN_FAIL (-2) : Unable to open archive 'bollywood/a/Anjaana Anjaani.zip' in wb mode

    gettings this error on linux centos

    working good on windows when i was checking script
    folder permissions are also 777


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
  •