开发者

php : Cannot reference current's file parent's folder subdirectory!

开发者 https://www.devze.com 2023-04-04 11:08 出处:网络
Please help! My directory structure is this: my_application my_application/index.php my_application/images

Please help!

My directory structure is this:

my_application
my_application/index.php
my_application/images
my_application/phpcode/my_script.php

I have this code in my_script.php

<?php
if(file_exists('../images)){
    // do something
}

?>

It works in wamp perfectly!!!

But when I upload it to my server (ho开发者_StackOverflowstgator), it doesn't work.

In my server I do not upload it to root folder, but to a subfolder.

rootfolder/folder1/folder2/my_application

From what I understand, .. is in reference to the root path, not the current file.

How can I reference the current's file parent's folder images?

Sorry for my English. Please help! I'm stuck on this one.


You can simpli use dirname($SCRIPT_FILENAME) to reference the direcotry of your current script.

Have a look at PHP Constant and PHP Reserved Variable :)

Hope this help

0

精彩评论

暂无评论...
验证码 换一张
取 消