how to display the uploaded zip file content in drupal? i created a cck file field and i uploaded zip file in that content type. Now i want to display the content of zip files after uploading the zip files. i don't know how to implement it?. can you tell me how to implement it?

thanks in advance.
It will not be very hard to accomplish. Don't let anyone tell you otherwise :D

What you need to do (if you have some experience with PHP and creating a very simple Drupal module) is download the PCLzip module which basically integrates the pclzip library into Drupal. There is no submodule for listing zip contents at the moment but it is very simple to make one if you keep in mind that there is a specific method in the library, the ListContent method.

You can see examples of how the methods of the library are used at the related projects that do use the pclzip module like PCLzip Folder or PCLzip Content Files. If you study their code, you will be able to achieve your goal very easily (and hopefully contribute your code back to the community).

Don't listen to advice that say: "extract the contents of the zip file first" since:


There is no need to extract files out of the zip file, you just need to see them
It's never a good idea to add extra complexity and write custom code that will be useful to nobody but you (and after a while so much custom code will be useless to you too)


Keep it simple: use the work of other people and expand it.

Edit: Let me give you an example so that you can understand how easy it is. If you check the pclzip module you will find a function that looks like this:

function pclzip_build_archive($filename) {
  // get the temp file
  global $pclzip_temp_file;
  $pclzip_temp_file = tempnam(file_directory_temp(), $filename);
  // build the archive
  require_once('pclzip/pclzip.lib.php');
  return new PclZip($pclzip_temp_file);
}


The line:

return new PclZip($pclzip_temp_file);


is the one that uses the PclZip method to create a new archive. All you need to do is create a new function, similar to that one, in your custom module, that will use the listContent method to list the contents of the zip file. It's that simple.

Notice, that there is one extra step after retrieving the contents of the zip file, and this is: "displaying them". Since the method of the pclzip library gives you back an array, it should be simple enough to display it (you can choose how you want to do it).

I have tested the following:


Installed the pclzip module
Made sure that the library is in the appropriate directory (according to pclzip instructions)
Added the following code in the pclzip.module file:




function pclzip_nodeapi(&amp;$node, $op) {

  $cckZip = $node-&gt;field_zipfile;
  $zipPath = $cckZip[0]['filepath'];
  $zipView = $cckZip[0]['view'];

  if (isset($zipPath)) {
    require_once('pclzip/pclzip.lib.php');
    $zip = new PclZip("$zipPath");

    if (($list = $zip-&gt;listContent()) == 0) {
      die("Error : ".$zip-&gt;errorInfo(true));
    }

    $zipView .= "&lt;div&gt;";

    for ($i=0; $i&lt;sizeof($list); $i++) {
      $zipView .= $list[$i]['filename'] . "&lt;br /&gt;";
    }

    $zipView .= "&lt;/div&gt;";



    switch ($op) {
      case "view":
        $node-&gt;content['body']['#value'] .= $zipView;
    }
  } 
}


Notice that:


field_zipfile is the name of the cck field that I used to upload the zip file
I have edited the pclzip module directly (which is not a very good idea). You should probably do the changes in your own module, but I just wanted to test the solution very quickly
You should decide where the filenames will be printed. I have just added them at the end of the node's content without any specific formatting. you can add classes and specific tags to the filenames in order to theme them if you want.