How to access files outside ftp server using file_exists

php file_exists not working
php check if file exists url
php check if image exists at url
file.exists r
php create directory
php file_exists url
php mkdir
php file_exists relative path

I want to monitor if the reference data is already uploaded or existing in our server. This is what I've tried..

$path= '\\\iserver\2019_Plans\013036456-2018\PDF-DATA\ASSEMBLE\013036456-2018.pdf';

if (file_exists($path)) {
    $tbody .= '<td>DATA ON SERVER</td>';
} else {
    $tbody .= '<td>NO DATA</td>';

It should display DATA ON SERVER on my table td if file exist. But it always output NO DATA even if the file exist.

I'm thinking that it doesn't access files or dir outside the ftp server. I'm currently using Notepad++ with Nppfttp plugin connected..

that's all we stored and access our website within our company.

this is the path where my php located :


and this is what I'am trying to access of check a file if exist(in my local C:)


So, how can access files outside of it?

Possible problem / solution

firts: Did you verify the permissions on the file?.

Second: Use ftp_get() (, it would be the most convenient.

file_exists - Manual, As of PHP 5.0.0, this function can also be used with some URL wrappers. file_exists() does NOT search the php include_path for your file, so don't use it before Even if the file doesn't exist you're still going to get 404 headers. If checking for a file newly created by an external program in Windows then file_exists() does� is the newest place to search, delivering top results from across the web. Content updated daily for ftp server online.

Try this solution:

// the server you wish to connect to - you can also use the server ip ex.
$ftp_server = "";

// set up a connection to the server we chose or die and show an error
$conn_id = ftp_connect($ftp_server) or die("Couldn't connect to $ftp_server");
// check if a file exist
$path = "/SERVER_FOLDER/"; //the path where the file is located

$file = "file.html"; //the file you are looking for
$check_file_exist = $path.$file; //combine string for easy use

$contents_on_server = ftp_nlist($conn_id, $path); //Returns an array of filenames from the specified directory on success or FALSE on error. 
// Test if file is in the ftp_nlist array
if (in_array($check_file_exist, $contents_on_server)) 
   echo "<br>";
   echo "I found ".$check_file_exist." in directory : ".$path;
   echo "<br>";
   echo $check_file_exist." not found in directory : ".$path;  

// output $contents_on_server, shows all the files it found, helps for debugging, you can use print_r() as well

// remember to always close your ftp connection

file_exists, Even if the file doesn't exist you're still going to get 404 headers. this code here is in case you want to check if a file exists in another server: Although PHP 5+ supports this function with FTP, it appears that file_exists() used on ftp for file outside open_basedir path, you will not be warned at log and file_exists returns� Looking for ftp to server? Get your questions answered. Explore informative articles and related content on

I have checked your code in my local. which is working file. I have checked with my local file path.

I think you have a problem with your path. confirm that the path is correct or not.

And also check the file permission which should have 755 or 777.

Here is my code

$path = 'C:\xampp\htdocs\test\XSCAssets\idea\157406374721215421965dd24e83bf2e7.png';

if (file_exists($path)) {
    $tbody = '<td>DATA ON SERVER</td>';
} else {
    $tbody = '<td>NO DATA</td>';
echo $tbody;

Unable to locate the source file. Please check your path, I have tried to upload a file using codeigniter ftp class. if you use file_exists with local files outside your web server. which means you must make sure that permissions allow users from network to access that file then may be it could work . We show you top results so you can stop searching and start finding the answers you need. Find ftp to server on

php, Try echoing "$_SERVER" and see where is the page exactly.. if the image was in the correct place and the .php file was in the correct place too, then "../resources/ additional/image.jpg" So as the FTP client displays the folder structure the image should be placed in if (file_exists($fileDir . $file)) { // Note:� As you see, we create an object of FtpWebRequest class and try to get the FileSize of the requested file. If the file exists, server will return the file size else it will throw an exception saying "File unavailable". In the catch block, we are catching the exception and checking for the ResponseCode from the response.

Accessing Files in compiled PHP Applications, To access files shipped with your application, or compiled into it, please see below. is run, it creates its own custom pluggable protocol (similar to HTTP, FTP, etc.) In other words, an application works like a small server combined with a client You can also keep PHP files outside the EXE and place them directly into a� Can you access the FTP server internally using your LAN address? If it works from the inside you need the to have someone try it using your WAN IP address from outside of your LAN. Use a real FTP client like filezilla instead of IE.

How to set proper permissions for Magento on server?, Download file from this link Magento Server Compatibility check and follow the (I'm not able to override any file) makes me believe your FTP user is not in the www-data inaccessible for serving by allowing the .htaccess files to regulate access. cleandir("var/session"); } if (file_exists("var/minifycache")) { echo " Clearing� This stored procedure takes four parameters 1)file to ftp 2)server name or IP 3)ftp login 4)ftp password SP will ensure that local file exists before continuing,