I there any way to Verify directory on intenet
Moderator: General Moderators
-
gaurav10in
- Forum Newbie
- Posts: 4
- Joined: Wed Aug 12, 2009 12:45 am
I there any way to Verify directory on intenet
I am setting up a website.
I need to find whether a directory has been created on my content web site or not.
Can anyone please tell me how to do this.
I was able to find the file by using fOpen() API.
I am in urgent need.
Thanks and Regards,
Gaurav Arora
I need to find whether a directory has been created on my content web site or not.
Can anyone please tell me how to do this.
I was able to find the file by using fOpen() API.
I am in urgent need.
Thanks and Regards,
Gaurav Arora
Re: I there any way to Verify directory on intenet
You can use the is_dir() function.
Example:
Example:
Code: Select all
$dir_name = "[b]some_directory_name_here[/b]";
if(is_dir($dir_name)) {
// dir exists, do your thing here
echo "Directory ".$dir_name." exists ";
}
else {
// dir does NOT exist
echo "Directory ".$dir_name." does not exist";
}
Last edited by neuroxik on Wed Aug 12, 2009 8:30 am, edited 1 time in total.
-
gaurav10in
- Forum Newbie
- Posts: 4
- Joined: Wed Aug 12, 2009 12:45 am
Re: I there any way to Verify directory on intenet
does it work for web based servers.
i think it only works for local directories.
i think it only works for local directories.
Re: I there any way to Verify directory on intenet
On your site? Then write some code for that site that checks for a directory and poll that.
Otherwise there's no way to tell if something is a directory or not remotely. You just can't know.
Wow... I actually said "right" instead of "write"...
Otherwise there's no way to tell if something is a directory or not remotely. You just can't know.
Wow... I actually said "right" instead of "write"...
Last edited by requinix on Wed Aug 12, 2009 7:02 am, edited 1 time in total.
Re: I there any way to Verify directory on intenet
As tasairis said, it's meant for your server (whether public or not).
If you take images/ (<- links to forums.devnetwork's images dir) for example, it's a dir, but it will return FALSE on is_dir, yet it is a dir. There'S also the fact that most dirs will be restricted, either via htaccess or by having an index file in the dir.
If you take images/ (<- links to forums.devnetwork's images dir) for example, it's a dir, but it will return FALSE on is_dir, yet it is a dir. There'S also the fact that most dirs will be restricted, either via htaccess or by having an index file in the dir.
Last edited by neuroxik on Wed Aug 12, 2009 4:16 am, edited 1 time in total.
-
gaurav10in
- Forum Newbie
- Posts: 4
- Joined: Wed Aug 12, 2009 12:45 am
Re: I there any way to Verify directory on intenet
Actually i am trying something like this:
//if directory exists on another server
if(is_dir("http://abc.com/accounts/"))
{
echo "Hello";
}
else
{
//do not allow user to proceed
exit("Error while trying");
}
It always shows me the Error message: "Error while trying".
Anyone please tell me its urgent.
Thanks for your help.
//if directory exists on another server
if(is_dir("http://abc.com/accounts/"))
{
echo "Hello";
}
else
{
//do not allow user to proceed
exit("Error while trying");
}
It always shows me the Error message: "Error while trying".
Anyone please tell me its urgent.
Thanks for your help.
Re: I there any way to Verify directory on intenet
As I said in the post above:
You need to play with local files (public or not)
Therefore, you get the (in your case you echo en error) error.neuroxik wrote:it's a dir, but it will return FALSE on is_dir
You need to play with local files (public or not)
Re: I there any way to Verify directory on intenet
If a site is using mod_rewrite for URL rewriting then there might not be a local directory, yet the URL "directory" will still exist. example.com/images/ could easily be mapped to /img ... creating a new directory called /images would consequently never work on website (or would break the website, depending whether or not the rewrite rule is set up with the L (last) directive). I think that is the issue that the poster is trying to work out - he needs to check if the website "directory" exists, not just whether there's an actual directory.neuroxik wrote:You need to play with local files (public or not)
Re: I there any way to Verify directory on intenet
One thing you can test for is if requesting the path without the trailing slash ends in a redirect to the same URL but with the slash. Apache, for one, does this on real directories.
Next, more complicated, is to get the page, then look for links in it that suggest the path is a directory. Like if you get /images and find that there's a "/images/picture.jpg", you can guess that /images can be treated as a directory.
Next, more complicated, is to get the page, then look for links in it that suggest the path is a directory. Like if you get /images and find that there's a "/images/picture.jpg", you can guess that /images can be treated as a directory.
Re: I there any way to Verify directory on intenet
No, you really can't. It's easy to rewrite URLs with mod_rewrite so that a directory like /img appears in every regard to be /images to the user. Directing /images/picture.jpg to /img/picture.jpg is trivial (and quite common).tasairis wrote:Next, more complicated, is to get the page, then look for links in it that suggest the path is a directory. Like if you get /images and find that there's a "/images/picture.jpg", you can guess that /images can be treated as a directory.