Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8170209
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T21:05:18+00:00 2026-06-06T21:05:18+00:00

firstly I don’t which is the correct stackExchange site to post this question if

  • 0

firstly I don’t which is the correct stackExchange site to post this question if the question is for other stack-site please remove my question.

Now let talk about the question: This situation is I have a file which is located in: /home/user/public_html/folder-one/folder-two/folder-three/file.php and the file must create archive of folder /folder-one with all files and sub-folders of /folder-one. I create the archive with system function (exec(), shell_exec() or system()) and it works perfect. My code is:

<?php
$output = 'zip -rq my-zip.zip /home/user/public_html/folder-one -x missthis/\*';
shell_exec($output);
?>

But when I download and open the archive the archive include the sub-folders as /home ; /user ; /public_html but this folders are totally unneeded and I wanna know how to create zip without them.

When I try with something like this $output = 'zip -rq my-zip.zip ../../../folder-one -x missthis/\*'; but then when I open the archive (on Windows 7 based OS) the name of folder-one is ../folder-one

Postscript: It will be better if somebody gives me correct $output the make zips on windows based hosting plans.

Best regards,
George!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T21:05:19+00:00Added an answer on June 6, 2026 at 9:05 pm

    By default, zip will store the full path relative to the current directory. So you have to cd into public_html before running zip:

    $output = 'cd /home/user/public_html; zip -rq my-zip.zip folder-one -x missthis/\*';
    shell_exec($output);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Firstly, please don't dismiss this question - I'm aware it's an ugly situation but
Firstly, This might seem like a long question. I don't think it is... The
Firstly, I realise that this is a very similar question to this one: Which
Firstly, please don't move to serverfault. It is indeed a programming question :-) We
Firstly, I'm aware of this question , but I don't believe I'm asking the
Firstly sorry if this is a common question but I couldn't find anything on
Firstly, I know this [type of] question is frequently asked, so let me preface
Firstly this is not a homework question. I am practicing my knowledge on java.
Firstly, please forgive me if I have asked this before (i suffer memory problems
Firstly, I don't know what to call this thing :) I want to know

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.