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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T20:18:14+00:00 2026-05-20T20:18:14+00:00

This is a tricky one and I’m not sure where to start, so any

  • 0

This is a tricky one and I’m not sure where to start, so any help will be grateful.

I have a parent folder called ‘source’ (c:/dev/source) which contains several child folders.

I need a PHP script that will display the child folders with checkboxes next to each, and a text field for a new folder name, allowing users to tick the checkboxes of the ones they want to copy to a ‘destination of c:/dev/destination/the_folder_name_they_typed_in

When they click submit, the selected child folders will be copied from c:/dev/source to c:/dev/destination/the_folder_name_they_typed_in

This is all running on a local internal development server. The child folders will always be in c:/dev/source/

  • 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-20T20:18:14+00:00Added an answer on May 20, 2026 at 8:18 pm

    Here’s a not well known little bit of code called DirectoryIterator. It’s not fully documented on the PHP site, but heres the jist of it:

    Create a list of files and folders with checkboxes next to them, slap them all in an array.

    $Directory = new RecursiveDirectoryIterator('c:/dev/source');
    $Iterator = new RecursiveIteratorIterator($Directory);    
    
    ?><form method="post"><?
    foreach($Iterator  as $r){
    
           if($r->isDot()) continue;
    
           echo "<input type=\"checkbox\" name=\"copy[]\" value=\"".($r->getSubPathName())."\"> ".$r->getSubPathName() . " <br>";
    
    }
    ?></form><?
    

    Now add this part to the top of the file

    <?php 
    if($_POST){
    if(is_array($_POST['copy'])) foreach($_POST['copy'] as $c){
     @copy($c, str_replace('c:/dev/source','c:/dev/dest', $c));
      echo "copied: $c to ". str_replace('c:/dev/source','c:/dev/dest', $c) . "<br>";
    
    }
    }
    

    I’m not fully sure what result you get from $r->getSubPathName() can you let me know if it outputs an array? if so it might be that you replace that with $r->getSubPath() and then add the “c:/dev/source” to the variable $c when you copy it?

    Further Reading:

    here

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

Sidebar

Related Questions

This is a tricky one, for me at least. I have a page that
Ok this is a tricky one. I have a list of Sets. I would
This is a tricky one and I've always relied on techniques, such as permission-based
This is a tricky one to explain (and very weird), so bear with me.
This is a tricky one because I don't see how I can fix it
PLEASE READ CAREFULLY : This is a bit unusual and you will be tempted
A long time ago I saw this trick in Ruby. Instead of doing (for
This is a bit of a long shot, but if anyone can figure it
This is starting to vex me. I recently decided to clear out my FTP,
This is kinda oddball, but I was poking around with the GNU assembler today

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.