alis5 Posted April 5, 2011 Share Posted April 5, 2011 Hello, I'm trying to have my index.php to open/run another test.php file. I'm having my own server that I play with, that I run Ubuntu on. So the index.php are located at /var/www/ directory, but I want to run a file that are located at /testing/test.php The final test.php is file for showing pictures, and I don't want to out all the pictures under the /var/www/ location. It's alot of photos. I don't know much about php but I have been trying this: <?php header("Location: /var/www/testing/test.php"); //These below are desperat old tries. //header("Location: ./testing/test.php"); //header("Location: ../testing/test.php"); //$handle = fopen("/privat/Web_pictures/test.php", "r"); //"/testing/test.php" // header("Location: ./test.php"); //This one actually works, but I'm still in the wrong folder (/var/www/) echo "test "; // NN4 requires that we output something... exit(); ?> Thankful for help! Quote Link to comment https://forums.phpfreaks.com/topic/232807-run-another-php-file-in-another-folder-on-the-linux-server/ Share on other sites More sharing options...
RussellReal Posted April 5, 2011 Share Posted April 5, 2011 the Location: header is a redirect for the browser, it doesn't execute anything until the user's client (browser) follows the redirect, but it will be unable to follow the redirect because the destination is outside of the public directory. what you CAN DO is include that file include('../../testing/test.php'); Quote Link to comment https://forums.phpfreaks.com/topic/232807-run-another-php-file-in-another-folder-on-the-linux-server/#findComment-1197460 Share on other sites More sharing options...
alis5 Posted April 5, 2011 Author Share Posted April 5, 2011 Tanks for the help! That took me one step further. But now I got stuck on original file (from SFPG). It's still showing the pictures from the /var/www/ directory. It's all has to do with the top lines (at least I think so). so I copied my tries in here. /* Single File PHP Gallery 4.1.0 (SFPG) */ error_reporting(0); // ----------- CONFIGURATION START ------------ define("GALLERY_ROOT", "../../testing/"); //My try after your comments above (with this the browser will just load and load the page...) // define("GALLERY_ROOT", "/testing/"); //Thought this would work // define("GALLERY_ROOT", "/testing/"); // define("DATA_ROOT", "./_sfpg_data/"); define("DATA_ROOT", "../..//testing/"); Quote Link to comment https://forums.phpfreaks.com/topic/232807-run-another-php-file-in-another-folder-on-the-linux-server/#findComment-1197467 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.