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

  • Home
  • SEARCH
  • 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 8495711
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T23:38:55+00:00 2026-06-10T23:38:55+00:00

How would I untar-gz a file in php without the use of exec(‘tar’) or

  • 0

How would I untar-gz a file in php without the use of exec('tar') or any other commands, using pure PHP?

My problem is as follows; I have a 26mb tar.gz file that needs to be uploaded onto my server and extracted. I have tried using net2ftp to extract it, but it doesn’t support tar.gz uncompressing after upload.

I’m using a free web host, so they don’t allow any exec() commands, and they don’t allow access to a prompt. So how would I go about untaring this?

Does PHP have a built in command?

  • 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-10T23:38:57+00:00Added an answer on June 10, 2026 at 11:38 pm

    Since PHP 5.3.0 you do not need to use Archive_Tar.

    There is new class to work on tar archive: The PharData class.

    To extract an archive (using PharData::extractTo() which work like the ZipArchive::extractTo()):

    try {
        $phar = new PharData('myphar.tar');
        $phar->extractTo('/full/path'); // extract all files
    } catch (Exception $e) {
        // handle errors
    }
    

    And if you have a tar.gz archive, just decompress it before extract (using PharData::decompress()):

    // decompress from gz
    $p = new PharData('/path/to/my.tar.gz');
    $p->decompress(); // creates /path/to/my.tar
    
    // unarchive from the tar
    $phar = new PharData('/path/to/my.tar');
    $phar->extractTo('/full/path');
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I would like to untar an archive e.g. tar123.tar.gz to directory /myunzip/tar123/ using a
I am trying to untar a tar file via popen ( from platform import
I'm trying to untar a file. Before untarring I would like to know free
I've found tons of pages saying how to untar tar.bz2 files, but how would
Would like to parse IPv4 address from exit-addresses . Format of the file: ExitNode
I am needing to download a very large file via PHP, the last time
Would appreciate some assistance i have a txt file witht he following contents: 1234|dog|apartment|two
Would there be any problems if I did the following to imitate a liked
I'm writing an iPhone app which downloads a tar-gzipped file from a Webserver, then
I have almost tar.gz file. I need to skip some bytes before unpacking and

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.