1

I am using PHP magic constant to move uploaded file to a new location, and the upload handler file location is inside "_inc" file inside the main application folder like this:

"path/tasksapp/_inc/upload_handelr.php"

So; when I use __DIR__ I get the path where the upload hander is exist:

"path/tasksapp/_inc/"

While the new location for uploaded file should be:

"path/tasksapp/uploads"

Is there's any option or attribute I can use with __DIR__ constant so I can change current directory to parent directory:

change:

"path/tasksapp/_inc/"

to be:

"path/tasksapp/"

4

1 回答 1

0

I recommend dirname(__DIR__):

  • it's portable (works on Windows where a/b/../c is not allowed)
  • it's readable
于 2015-09-29T20:51:57.490 回答