Pixelknight1398 Pixelknight1398 - 2 months ago 12
PHP Question

How do I solve this php is_dir code?

I have a folder in my website named GameUploads and I am trying to use is_dir to test if it's is a directory, which I assumed meant the same as folder. The php code I run is in .../php/test.php and the folder I'm trying to reach is .../GameUploads/ where '...' is the url to the webpage. My code is here:

//initiate file check
$check_dir = "../../GameUploads/";

echo "$check_dir is a directory";
echo "$check_dir is not a directory";


I'm not sure what I was trying to do with
but originally is was just
which returned false, and then I entered
which returned true. I guess I'm trying to find a way to check if GameUploads is a directory from the php file. How can I do this? I'm not quite understanding how to use
very well... I have already read through php.net and w3schools


"Yes the full server path works! Thank you haha I am satisfied now. I am curious now as to why the server path worked but not the website URL. I will have to poke around but thanks again! – Pixelknight1398"

As I stated in comments:

Use a full server path.



You may have to add a trailing slash at the end.

"I am curious now as to why the server path worked but not the website URL."

As per what the manual states:

As of PHP 5.0.0, this function can also be used with some URL wrappers. Refer to Supported Protocols and Wrappers to determine which wrappers support stat() family of functionality.

You will need to use CURL instead, if that is available for you to use.