views:

30

answers:

2

Hello!

How can I use is_file with a path like: /folder/file.jpg please?

Thank you!

+2  A: 

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';
Jurian Sluiman
Thank you, Jurian.
Francisc
+1  A: 

Use $_SERVER['DOCUMENT_ROOT']:

$is_file = is_file($_SERVER['DOCUMENT_ROOT'] . '/folder/file.jpg');
Jacob Relkin
Thank you, Jacob.
Francisc