0

I'am using the script below from this post LAMP: How to create .Zip of large files for the user on the fly, without disk/CPU thrashing

header('Content-Type: application/octet-stream');
header('Content-disposition: attachment; filename="file.zip"');

// use popen to execute a unix command pipeline
// and grab the stdout as a php stream
// (you can use proc_open instead if you need to
// control the input of the pipeline too)
//

$fp = popen('zip -r - tmp/01-55-34_561764e6cb06e', 'r');

// pick a bufsize that makes you happy (8192 has been suggested).
$bufsize = 8192;
$buff = '';
while( !feof($fp) ) {
   $buff = fread($fp, $bufsize);
   echo $buff;
}
pclose($fp);

I have my files in the folder: tmp/01-55-34_561764e6cb06e

I get a working zip file but the problem is that I also get the path included in my zip file.

My zipfile looks like this when I open it

tmp/01-55-34_561764e6cb06e/image1.jpg
tmp/01-55-34_561764e6cb06e/image2.jpg
tmp/01-55-34_561764e6cb06e/image3.jpg
tmp/01-55-34_561764e6cb06e/image4.jpg

I just want to have the images, without the folders (tmp/...).

File structure

/var/www/html/script.php
/var/www/html/tmp/01-55-34_561764e6cb06e/image1.jpg
/var/www/html/tmp/01-55-34_561764e6cb06e/image2.jpg
/var/www/html/tmp/01-55-34_561764e6cb06e/image3.jpg

I don't want to have my script in the same folder as the images!

Community
  • 1
  • 1
Xtreme
  • 1,420
  • 7
  • 25
  • 46

1 Answers1

0

Found

-j

--junk-paths Store just the name of a saved file (junk the path), and do not store directory names. By default, zip will store the full path (relative to the current directory).

Xtreme
  • 1,420
  • 7
  • 25
  • 46