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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T14:53:07+00:00 2026-05-13T14:53:07+00:00

I wrote a basic content-management system for my website, including an administration panel. I

  • 0

I wrote a basic content-management system for my website, including an administration panel. I understand basic file IO as well as copying via PHP, but my attempts at a backup script callable from the script have failed. I tried doing this:

//... authentication, other functions
for(scandir($homedir) as $buffer){
    if(is_dir($buffer)){
        //Add $buffer to an array
    }
    else{
        //Back up the file
    }
}
for($founddirectories as $dir){
    for(scandir($dir) as $b){
        //Backup as above, adding to $founddirectories
    }
}

But it did not seem to work.

I know that I can do this using FTP, but I want a completely server-side solution that can be accessed anywhere with sufficient authorization.

  • 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-13T14:53:07+00:00Added an answer on May 13, 2026 at 2:53 pm

    Here is an alternative though: why don’t you Zip the source directory instead?

    function Zip($source, $destination)
    {
        if (extension_loaded('zip') === true)
        {
            if (file_exists($source) === true)
            {
                $zip = new ZipArchive();
    
                if ($zip->open($destination, ZIPARCHIVE::CREATE) === true)
                {
                    $source = realpath($source);
    
                    if (is_dir($source) === true)
                    {
                        $files = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($source), RecursiveIteratorIterator::SELF_FIRST);
    
                        foreach ($files as $file)
                        {
                            $file = realpath($file);
    
                            if (is_dir($file) === true)
                            {
                                $zip->addEmptyDir(str_replace($source . '/', '', $file . '/'));
                            }
    
                            else if (is_file($file) === true)
                            {
                                $zip->addFromString(str_replace($source . '/', '', $file), file_get_contents($file));
                            }
                        }
                    }
    
                    else if (is_file($source) === true)
                    {
                        $zip->addFromString(basename($source), file_get_contents($source));
                    }
                }
    
                return $zip->close();
            }
        }
    
        return false;
    }
    

    You can even unzip it afterwards and archive the same effect, although I must say I prefer having my backups compressed in zip file format.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a site which is using DNN (DotNetNuke) as a content management system.
I understand, at least on paper, the basic difference between the Content Provider and
I need to write an error log to a XML file using Visual Basic
I wrote a simple batch file as a PowerShell script, and I am getting
I have created a very basic service operation that needs to write content to
I'm creating my own template engine using PHP. The basic idea is that for
Very basic question: how do I write a short literal in C++? I know
I am looking for basic examples/tutorials on: How to write/compile libraries in C++ (
I am using C to write a DLL that provides basic database connection functionality
Wrote the following in PowersHell as a quick iTunes demonstration: $iTunes = New-Object -ComObject

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.