Hello!
How can I use is_file with a path like: /folder/file.jpg please?
Thank you!
Hello!
How can I use is_file with a path like: /folder/file.jpg please?
Thank you!
If the path starts with a / this means the path is absolute. When the path is relative (ie not starting with /) then the path relative to the php script is taken. If you want to have /folder/file.jpg relative to the server root, you can append the root.
$path = $_SERVER['DOCUMENT_ROOT'] . '/folder/file.jpg';
Use $_SERVER['DOCUMENT_ROOT']
:
$is_file = is_file($_SERVER['DOCUMENT_ROOT'] . '/folder/file.jpg');