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


How to check local path ?





Philip
Uhm, how to get a local directory in php ?
if am working a file that www.google.com/beta/index.php
then how can i get http://www.google.com/beta <-- i want this directory Smile

and can files_exist checking a file that on other;s domain ?

thanks Smile
TomS
Code:
<?php
$path="http://www.google.de/dir/file.php";
$str=dirname($path);
echo $str; #should be http://www.google.de/dir/
?>


Don't know the second thing. But wonder how it's possible, too.
If anyone knows, please post here... Thx
hexkid
Philip wrote:
Uhm, how to get a local directory in php ?
if am working a file that www.google.com/beta/index.php
then how can i get http://www.google.com/beta <-- i want this directory Smile

"http://www.google.com/beta" is NOT a local directory.
Do you want the local directory for something on your server, or the URL of the directory of a specific URI?

Anyway check the $_SERVER variable. It has everything you need either way.
Code:
<?php
echo '<pre>'; print_r($_SERVER); echo '</pre>';
?>


Philip wrote:
and can files_exist checking a file that on other;s domain ?


Code:
<?php
$external_file = 'http://www.yahoo.com/index.html';

if (ini_get('allow_url_fopen') == '1') {
  $f = @fopen($external_file, 'rb');
  if (!$f) {
    echo 'External File ("', $external_file, '") does not exist.', "<br>\n";
  } else {
    $data = fread($f, 100);
    fclose($f);
    echo 'External File ("', $external_file, '") exists. It\'s first 100 bytes are:', "<br>\n";
    echo htmlentities($data);
  }
} else {
  echo 'The current PHP configuration disables accessing URL object files.', "<br>\n";
}
?>
Philip
so we need to $f=fopen('filelink'); and $data=fread($f,byte) and fclose($f);

echo the $data,

if failed to open then the files isnt exist
and if file opened that link must be exist ? right that ? Smile

thanks
Related topics
751 Useful Windows XP Files
PEAR path
Stats
[RESOLVED] Awstats Error
Rose Bowl = Vince Young Bowl
Frontpage
Which Linux distribution is the best?
Your online routine
Switching Hosts, help me!
HOW MUCH DO YOU PAY FOR YOUR HOUSES OR APARTMENTS
Moving Joomla from one server to another
Importing mails from Outlook express to Outlook - 2 computer
Uploader not working.
Beer Brewing
Reply to topic    Frihost Forum Index -> Scripting -> Php and MySQL

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