SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Addict
    Join Date
    Nov 2009
    Posts
    283
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Zip & Download script without PHP's Zip extension

    Hi,

    I know that you can zip and download files/folders with PHP, I actually have a script that does this. The script uses ZipArchive class which requires PHP's Zip extension to be installed/activated.

    Is it possible to have a "zip & download" script which doesn't require that extension?

    Thanks for any ideas.

  2. #2
    SitePoint Addict bronze trophy vectorialpx's Avatar
    Join Date
    Dec 2012
    Location
    Bucharest
    Posts
    219
    Mentioned
    7 Post(s)
    Tagged
    0 Thread(s)
    You may try the unzip UNIX command, and use it with exec or ``

  3. #3
    SitePoint Addict
    Join Date
    Nov 2009
    Posts
    283
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by vectorialpx View Post
    You may try the unzip UNIX command, and use it with exec or ``
    No idea what that does but I am not trying to unzip, I am trying to zip and download.

    I found another script that uses exec() function of PHP but it doesn't work if safe mode is enabled. I may use that but I am still looking for alternative options.

  4. #4
    SitePoint Addict bronze trophy vectorialpx's Avatar
    Join Date
    Dec 2012
    Location
    Bucharest
    Posts
    219
    Mentioned
    7 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by nayen View Post
    No idea what that does but I am not trying to unzip, I am trying to zip and download.
    I found another script that uses exec() function of PHP but it doesn't work if safe mode is enabled. I may use that but I am still looking for alternative options.
    My bad, I wanted to say `zip` but, with safe-mode enabled...
    Quote Originally Posted by http://php.net/manual/en/function.exec.php
    Note: When safe mode is enabled, you can only execute files within the safe_mode_exec_dir. For practical reasons, it is currently not allowed to have .. components in the path to the executable.
    Without exec or passthru or "` operator", I cannot see a solution - you need an external program to do the job.

    So, you may try
    Code:
    exec("zip -r output/files.zip path/to/dir");
    Do it with error_reporting(E_ALL) so you'll know for sure if it works.


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
  •