Coder Social home page Coder Social logo

Zipping without folder name about zippy HOT 3 CLOSED

alchemy-fr avatar alchemy-fr commented on July 28, 2024
Zipping without folder name

from zippy.

Comments (3)

romainneutron avatar romainneutron commented on July 28, 2024

This is because zippy works from your current working directory.

Use this code, it should solve your issue :

$source_dir = '/my/path/to/dir'
$mapping = [];
foreach (new \DirectoryIterator($source_dir) as $file) {
    if ($file->isDot()) { 
        continue; 
    }
    $mapping[$file->getBasename()] = $file->getRealPath();
}

$zippy->create('myarchive.zip', $mapping);

from zippy.

cdarken avatar cdarken commented on July 28, 2024

Awesome, just tested it, it works. But it looks like the zip file should have full path specified, like __DIR__ . '/myarchive.zip'.
I wonder if it should detect the original working dir and append to it in case it doesn't have full path.
First time I tested it, it was creating the archive inside the temp dir in /tmp and I was wondering what I was doing wrong.
Anyway, it works now. Thanks a lot.

from zippy.

hglattergotz avatar hglattergotz commented on July 28, 2024

Would be nice if this info were in the docs.

from zippy.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.