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

Related Questions

I have a photoshop plugin for a file format Ive written in c++ that
I have an Eclipse plugin project that has several file resources that I would
Say I have the following file structure: app/ app.py controllers/ __init__.py project.py plugin.py If
I have to upload a 3gp audio file to my server using MultipartEntity. i
I have strange problem. I have own remote repository and upload their plugin. Then
I have a remote SVN server, where I keep my files (for web devel).
I have file upload using jquery form plugin as $(function() { $(#Form).ajaxForm({ iframe: true,
i have a form with input type=file. it submits using ajax (plugin jquery form
I install plugin open_id_authentication and have this error: /usr/lib/ruby/gems/1.9.1/gems/activesupport-3.0.0.beta/lib/active_support/dependencies.rb:167:in `require': no such file to
I have downloaded several new plugins which come with a help file. None of

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.