Normally you can find out if a particular file exists on the server by calling the file_exists() functiion but in case you are working with a password-protected server, this functionwould fail as the user authentication has not taken place.
However, there is a workaround to this and I am going to describe it below-
Step 1 : The first thing you need to do is to create an access variable in the setting like :
$access = “username:password@”;
Step 2 : you have to use this access value in your url like
Now append the variable to the URL. If your url ishttp://www.mywebsite.com – you have to create the url for the file_exists function like the following.
$url = “http://”.$access.”mywebsite.com”;
Step 3 : Use this as your absolute path to check if your file exists or not.
Similarly if you are using the file_get_contents() in your script to grab html codes of a remote site, the function will give warning and fail if the site employs user authentication. The above hack can be applied in this instance also to overcome security issues.