Questions tagged [realpath]

The canonical path of the specified filename.

The canonical path of the specified filename, eliminating any symbolic links encountered in the path (if they are supported by the operating system)

127 questions
5
votes
4 answers

How can I tune the PHP realpath cache?

Recent versions of PHP have a cache of filenames for knowing the real path of files, and require_once() and include_once() can take advantage of it. There's a value you can set in your php.ini to set the size of the cache, but I have no idea how to…
Andy Lester
  • 91,102
  • 13
  • 100
  • 152
5
votes
3 answers

getServletContext().getRealPath() doesn't work in controller (NPE), but works in jsp

I am trying to add image to my pdf file. Image is located in "WebContent/img/image.png". First I save relative path to string and then I convert this relative path to real path. String relativeWebPath = "/img/image.png"; String absoluteDiskPath =…
Juraj Vlahović
  • 400
  • 2
  • 4
  • 12
5
votes
8 answers

Get WordPress installation folder path

Is there a way to get the path to where WordPress is installed? I was using the following: $root = realpath($_SERVER["DOCUMENT_ROOT"]); It is fine for www.example.com -> /usr/local/pem/vhosts/165312/webspace/httpdocs It is not fine for…
user983248
  • 2,588
  • 7
  • 24
  • 44
4
votes
2 answers

Are realpath() portability concerns obsolete?

The traditional way to call the Unix realpath() function has been realpath(pathname, buf) where buf is a user-supplied buffer with room for PATH_MAX bytes. This is problematic since PATH_MAX is unnecessarily big for most filenames and yet can be…
Lassi
  • 3,522
  • 3
  • 22
  • 34
4
votes
2 answers

C realpath function doesn't work for strings defined in the source file

I'm having a weird problem with the realpath function. The function works when it is given a string received as an argument for the program, but fails when given a string that I define in the source code. Here is a simple program: #include…
Jona
  • 669
  • 10
  • 18
3
votes
2 answers

Why does realpath() return error EEXIST?

My program is running in a Linux environment, compiled with gcc version 4.4.7. I am using realpath() to "canonicalize" file paths. The path of every directory and file I feed to realpath() definitely exists, which of course is essential for…
Mike Finch
  • 746
  • 1
  • 7
  • 20
3
votes
1 answer

How to get realpath for virtual paths?

if path is ../b and current directory is /var/www/a/c, then realpath would be /var/www/a/b but if b doesn't exist, realpath() returns false. Is it possible to get the same path even if directory doesn't exist yet?
Alex
  • 66,732
  • 177
  • 439
  • 641
3
votes
3 answers

Getting base url, development variable, the best way, without using globals

In my application architecture I want to replace my globals with something that ain't gonna burn most of the developer's eyes, because I am using globals like this, define('DEVELOPMENT_ENVIRONMENT', true); // Shorten DIRECTORY_SEPARATOR…
Joey Hipolito
  • 3,108
  • 11
  • 44
  • 83
3
votes
3 answers

PHP find require_once real path

i need to require_once this files main.class.php and functions.php and config.php to admin/test.php. how to php find require real path?! NOTE: main.class.php in class folder , functions.php in includes folder and config.php in root directory and…
B.B King
  • 111
  • 2
  • 3
  • 7
3
votes
1 answer

Protecting from LFI-like vulnerabilities when the file doesn't exist yet

If a user was requesting a file on a service, I could normally protect them from accessing documents outside the scope of what I want by using PHP's realpath() and ensuring it is under the root directory. Such as like this: $path =…
Chris Foster
  • 2,639
  • 2
  • 23
  • 30
3
votes
1 answer

realPath for MockHttpServletRequest

I am writing a Spring based Test case for my Spring Controller, in my controller we are using like this "request.getSession().getServletContext().getRealPath("/myFolderName");" Its working fine for normal requests, but for unit test cases like…
2
votes
2 answers

Sanitizing File Paths in PHP

In PHP, is there a function that can perform logic similar to realpath() but on files that may not exist in the filesystem? Obviously it would not be able to resolve links etc, but my goal is to see if a path provided by a user is in a certain…
jmkelm08
  • 677
  • 6
  • 15
2
votes
1 answer

VueJS + Vite runs into error on build. Error: EINVAL: invalid argument, realpath

We have a problem in our NodeJS environment on the servers of ProfiHost (German provider) using Vite in a VueJS app. Installing the deps via npm i works fine. However, the build via npm run build always runs with the following error: failed to load…
Tobi360
  • 188
  • 1
  • 10
2
votes
0 answers

What's the behind magic of python os.path.realpath?

Recently, I tried to install pypoetry on my windows. The python I used was installed from MS store. And I found something strange. C:\Users\Liu.D.H>where…
Donghua Liu
  • 1,776
  • 2
  • 21
  • 30
2
votes
1 answer

How to grab url path to file in php

For sending a link to a email (confirming subscription). i need the path to the file subscribe.php. On my webserver, the file subscribe.php is in the webroot. External access will be: http://newsletter.mydomain.com/subscribe.php This is the link in…
john
  • 1,263
  • 5
  • 18
1
2
3
8 9