FRIHOST FORUMS SEARCH FAQ TOS BLOGS COMPETITIONS
You are invited to Log in or Register a free Frihost Account!


Going UP a Directory with php?





jerredk
Hello all. Smile

I have a question;
I was wondering if you could go Up a directory with php? I would like to use this in a site transfer system I'm trying to make; also it will become part of my self-hecking script.
(This will nog be a vulnerable hacking script; as you already need to be able uploading to the host)
Also it should be able replacing a file uploaded in the same directory as the php script to several directories up.

Example:

Script/page are uploaded at:
Code:

www.website.com/directory1/directory2/script1.php
www.website.com/directory1/directory2/index2.html


Then you make a script that it will go up 2 directories; so you land here:
Code:
www.website.com/

and it will replace the index2.html here:
Code:
www.website.com/index2.html


and perhaps even transfer the 'index.html' standard page from the main directory up to the scripts directory. Smile

Would this be possible?
And if so; which php commands should I use?
(I'll write the rest of the script myself)

Thanx in Advance;
~ Jerredk
rvec
just like in html you can go up a dir by putting .. in the url. For example if your index file in on www.example.com/test/index.php and your img is on http://www.example.com/test.jpg you can open it with ../test.jpg.

To go up 2 dirs just use ../../

I am not totally sure what you want to do but make sure you don't give non-logged in members too many permissions.
pollux1er
do you want to know the script to redirect a page to another??

For example, typing the page 1 in the address bar automatically redirect you to another pae?

if it is that let me know.
SlowWalkere
pollux1er wrote:
do you want to know the script to redirect a page to another??

For example, typing the page 1 in the address bar automatically redirect you to another pae?

To just redirect the user, you can use the header("Location: url") function.

Code:
header('Location: http://www.domain.com/index.html');


That will redirect from the current script to a new page. However, this won't work if you've already displayed any output on the page.

- Walkere
DanielXP
I think this works

Code:
../../index2.html


It should be better than doing a redirect
D'Artagnan
Quote:
To go up 2 dirs just use ../../

works fine,

Or you can refeer the whole path under / like

/index2.php -- will get the path throught the root directory even if you are in a subdirectory


Just be aware that the functions inherit the callers Path ...
rvec
problem solved -close-
If the topic starter has more questions to ask here please pm me I'll reopen it.
Related topics
req: PHP to list files in directory, and link to them
PHP: Directory listing code
Simple PHP Navigation
Scripts Available on Frihost
Can Google Hack?
PHP/Mysql - beginner!
A very good PHP MySQL Tutorial
Database for Dentists
Where to start?
Link directory Php Free application
Starting with PHP
what is wrong with this query? Please please help!
php/mysql for pc use
Wordpress: Php is not running
This topic is locked: you cannot edit posts or make replies.    Frihost Forum Index -> Scripting -> Php and MySQL

FRIHOST HOME | FAQ | TOS | ABOUT US | CONTACT US | SITE MAP
© 2005-2011 Frihost, forums powered by phpBB.