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

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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T20:01:51+00:00 2026-06-09T20:01:51+00:00

I have a php script that resides in a single folder I want to

  • 0

I have a php script that resides in a single folder
I want to run the same script in each folder wihout manually uploading the php file in each file

for example I have
mysite.com/folder/script.php

and folder has different subfolders

so I want to create a php file that will execute this script.php in each folder/subfolder without manually uploading the script.php in each folder

Is there a way ?

Update php code

$path = array("./files/","./images/");
$path2=  array("http://".$_SERVER['SERVER_NAME'].dirname($_SERVER["PHP_SELF"])."/files/","http://".$ _SERVER['SERVER_NAME'].dirname($_SERVER["PHP_SELF"])."/images/");
$start="";
$Fnm = "./include.php";
$inF = fopen($Fnm,"w");
fwrite($inF,$start."\n");

$folder = opendir($path[0]);
while( $file = readdir($folder) ) {
       if (($file != '.')&&($file != '..')&&($file != 'index.htm')) {
            $folder2 = opendir($path[1]);
            $imagename ='';
            while( $file2 = readdir($folder2) ) {
                if (substr($file2,0,strpos($file2,'.')) == substr($file,0,strpos($file,'.'))){
                    $imagename = $file2;
                }
            }
            closedir($folder2);
        $result="{\nlevels: [\n{ file: \"$path2[0]$file\" }\n],\nimage: \"$path2[1]$imagename\",\ntitle: \"$file\"\n},\n";
        fwrite($inF,$result);
       }
}
fwrite($inF,"");
closedir($folder);

fclose($inF);
  • 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-09T20:01:52+00:00Added an answer on June 9, 2026 at 8:01 pm

    Assuming you are using Apache, you could use mod_rewrite by creating a htaccess file that looks like this:

    RewriteEngine on
    RewriteBase /folder/
    RewriteRule  ^.+/script.php$ script.php
    

    And uploading it to your server. This turns the RewriteEngine on, sets the base directory to your chosen folder, then whenever script.php is requested in a subdirectory it will return /folder/script.php

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

Sidebar

Related Questions

I have a php script that is reading a file in (file_get_contents). I want
I have a php script that i run via command line like php file.php
I have a php script that watches for the newest json file in a
I have a PHP script that executes a .bat file using system(cmd /c C:\dir\file.bat);
I have a PHP script that needs to run some pretty hefty imagemagick commands.
I have a php script that takes a file's id in the url, finds
So I have a PHP script file that resizes images on the fly. While
I have a php script that needs to run once every 5 minutes. Currently
I have php script that creates a temporary watermark image for users that are
I have a php script that inserts data from an Android app into a

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.