2

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/"

CairoCoder
  • 3,091
  • 11
  • 46
  • 68

1 Answers1

1

I recommend dirname(__DIR__):

  • it's portable (works on Windows where a/b/../c is not allowed)
  • it's readable
Eugen Rieck
  • 64,175
  • 10
  • 70
  • 92
  • 1
    Inside `upload_handelr.php` something like `$dir=dirname(__DIR__)` would create a variable pointing to the upload directory. Append the filename use `move_uploaded_file()` – Eugen Rieck Sep 29 '15 at 21:03