PHP Classes

Storing Paths in ZIP

Recommend this page to a friend!

      Zip and File Splitter  >  All threads  >  Storing Paths in ZIP  >  (Un) Subscribe thread alerts  
Subject:Storing Paths in ZIP
Summary:Trying to find out how to stop storing paths in the zip file
Author:Henry Wills
Date:2008-04-10 11:18:37
Update:2012-06-13 12:29:00

  1. Storing Paths in ZIP   Reply   Report abuse  
Picture of Henry Wills Henry Wills - 2008-04-10 11:18:38
Hi, does anyone happen to know how to NOT store the path in the zip file? I am pulling files from a UNIX file path because they are not in the webpath, so my zip ends up with /var, /www .. etc as folders and all I need are the files with no paths.


  2. Re: Storing Paths in ZIP   Reply   Report abuse  
Picture of Bas de Ruiter Bas de Ruiter - 2012-06-13 12:29:00 - In reply to message 1 from Henry Wills
I too found this anoying.
After searching for a solution to this, I eventually cam up with the simple solution to just first go to the directory before zipping the file.

// the input file
$file = '/path/to/file.txt';
$path = pathinfo($file, PATHINFO_DIRNAME);
$filename = basename($file);
// first change directory
// then create zip file
require_once 'EasyZip.php';
$zip = new EasyZip();

For more information send a message to info at phpclasses dot org.