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 621091
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T18:50:10+00:00 2026-05-13T18:50:10+00:00

I have a wp plugin file on server B who’s purpose is to retrieve

  • 0

I have a wp plugin file on server B who’s purpose is to retrieve a zip file from a remote server A.

Once Server B receives the zip file, it should extract the contents and copy the files into a specific folder on server B overwriting any existing files.

I have some code below that I’ve borrowed from a file that uses and uploader to do the same thing and I’d just like to redo it for the automated server to server procedure described above. But I’m getting a fatal error when trying to Activate this plugin.

function remote_init() 
{
    openZip('http://myserver.com/upgrade.zip');
    $target = ABSPATH.'wp-content/themes/mytheme/';
}


function openZip($file_to_open, $debug = false) { 
    global $target;
    $file = realpath('/tmp/'.md5($file_to_open).'.zip');

//$file is always empty. can’t use realpath in this case. What to do?

    $client = curl_init($file_to_open);
    curl_setopt(CURLOPT_RETURNTRANSFER, 1);

    $fileData = curl_exec($client);

    file_put_contents($file, $fileData);

    $zip = new ZipArchive();  
    $x = $zip->open($file);  
    if($x === true) {  
        $zip->extractTo($target);  
        $zip->close();  

        unlink($file);  
    } else {
        if($debug !== true) {
            unlink($file);
        }  
        die("There was a problem. Please try again!");  
    }  
} 


add_action( 'init','remote_init');
  • 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-05-13T18:50:10+00:00Added an answer on May 13, 2026 at 6:50 pm

    I did a quick check in the manual, and there was a slight error on line 5.

    $target = ABSPATH .'wp-content/themes/mytheme/';
    function openZip($file_to_open, $debug = false) { 
        global $target;
        $file = ABSPATH . '/tmp/'.md5($file_to_open).'.zip';
        $client = curl_init($file_to_open);
        curl_setopt($client, CURLOPT_RETURNTRANSFER, 1);  //fixed this line
    
        $fileData = curl_exec($client);
    
        file_put_contents($file, $fileData);
    
        $zip = new ZipArchive();  
        $x = $zip->open($file);  
        if($x === true) {  
            $zip->extractTo($target);  
            $zip->close();  
    
            unlink($file);  
        } else {
            if($debug !== true) {
                unlink($file);
            }  
            die("There was a problem. Please try again!");  
        }  
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 349k
  • Answers 349k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Take a look at this SO question - it addresses… May 14, 2026 at 6:51 am
  • Editorial Team
    Editorial Team added an answer These two routes {controller}/{action}/{id} and {controller}/{action}/{name} are ambiguous. It cannot… May 14, 2026 at 6:51 am
  • Editorial Team
    Editorial Team added an answer I'm assuming you're talking about this: http://dublincore.org/ It's certain that… May 14, 2026 at 6:51 am

Related Questions

I'm running wordpress 2.8.6 as fcgi with safe_mode=on, on plesk9/centOS64. wordpress was installed by
I moved from a shared hosting to a VPS a few weeks ago and
I have tested the below script on a demo page which is not using
This is probably a Wordpress issue more than a Friendfeed issue but could be
i use win7 + VS2008 PRO to edit my blog (php) and i can't

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.