Questions tagged [file-exists]

A "FileExists" method provides a mechanism to determine if a specified path/file exists.

Overview

FileExist methods, which are available in most languages, typically have a path/filename parameter and return a Boolean value, indicating whether the file exists.

Implementations

The following links provide reference to the method descriptions for various languages:

606 questions
5
votes
3 answers

How to keep checking for a file until it exists, then provide a link to it

I'm calling a Java program with a PHP system call. The Java program takes a while to run but will eventually produce a PDF file with a known filename. I need to keep checking for this file until it exists and then serve up a link to it. I assume a…
Nick Brunt
  • 9,533
  • 10
  • 54
  • 83
5
votes
2 answers

Is this the correct way of checking if a file exists?

I am trying to check if a file (image) exists so I can delete it before uploading the new one. This is what i've tried so far: foreach (glob("../imgs/" . $name . ".*") as $file) { if (file_exists($file)) { unlink($file); } } Is this…
SomeBeginner
  • 49
  • 1
  • 3
  • 17
5
votes
4 answers

Multiple File Exists Checking? A Better way?

I have a script. It recieves a variable called $node, which is a string; for now, lets assume the variable value is "NODEVALUE". When the script is called, it takes the variable $node, and tries to find an image called NODEVALUE.png. If it cant find…
Jason Axelrod
  • 7,155
  • 10
  • 50
  • 78
5
votes
4 answers

determining if a flash drive exists from a batch file without error messages

I have batch files with the construct: if exist F:\ copy /y Application.exe F:\ at the end of a compile, to copy the executable to a USB key if it is plugged in. It has worked fine with USB keys but when I had a USB multi card reader plugged in…
rossmcm
  • 5,493
  • 10
  • 55
  • 118
5
votes
4 answers

Matlab 'exist' returns 0 for a file that definitely exists!

I'm running Matlab 7.8.0 under Windows. I am calling an external utility using dos() which creates a file in the current directory. I the file is created correctly, but it cannot be seen by exist or fopen, which return 0 and -1 respectively. The…
Sanjay Manohar
  • 6,920
  • 3
  • 35
  • 58
5
votes
2 answers

File.Exists acts differently when access is denied to the file vs denied to the dir

Based on the MSDN documentation of File.Exists, the File.Exists method should return false on any error, including the caller not having access to read the file. I would expect it to return false both when the file is set to FullControl denied to…
Middas
  • 1,862
  • 1
  • 29
  • 44
5
votes
1 answer

file_exists or getimagesize only work with local, absolute file paths, but not with URLs in PHP

I recently updated one of my servers and since then, I have an issue with some specific PHP commands (see below). I believe it is a configuration issue, but I already looked into a couple of things and do not know any further. So maybe one of you…
Sebastian
  • 109
  • 6
5
votes
1 answer

Android checks if file exists in a remote server using its URL

I want my Android program to check if file (e.g. index.php) exists in a remote server using its URL. i.e. if I click the button, it should check if a url exists. If it does, it should load that same URL otherwise display a message "File does not…
Joy
  • 75
  • 1
  • 7
5
votes
2 answers

file_exists and paths that include relative paths ("/../")

When I use file_get_contents on a path like /a/path/to/a/../file.php, it gets the content just fine. If I call file_exists first (or is_file or realpath), the return values indicate that the file does not exist. What seems to be the issue? Edit:…
DudeOnRock
  • 3,685
  • 3
  • 27
  • 58
5
votes
1 answer

PHP: file_exists vs stream_resolve_include_path - What Performs Better?

It seems as of late there has been a fair amount of wondering on by php developers on whether it is better to use file_exists() or stream_resolve_include_path() when doing checks of whether or not a file exists (be it for including them, caching…
Abela
  • 1,225
  • 3
  • 19
  • 42
5
votes
7 answers

PHP File Exists Always False

I have a case where file_exists() is always returning false. My latest attempt was to just test to see if it would return true for $_SERVER["SCRIPT_FILENAME"] and then return the value of the path if it couldn't find the file which it does. The…
Joe
  • 51
  • 1
  • 3
5
votes
5 answers

file_exists() for a file that contains (&) in filename

$filename = "Sara & I.mp3"; if (file_exists($filename)) { ... } If the filename has a "&" PHP does not return true for file_exists How can I escape "&" in the $filename for the file_exists to work? Already tried urlecode(), urlrawencode(),…
user191778
5
votes
3 answers

file_exists doesn't seem to work correctly

I've got a php-script that i want to execute, only if an other instance of the script isn't already running. I've got this code: $lockfile = __DIR__.'/lock.file'; if(file_exists($lockfile) == false) { echo 'no lockfile. Job will execute.'; …
wjhulzebosch
  • 175
  • 3
  • 11
5
votes
3 answers

Check If A Portion Of A Filename Exists

So I know in the following code example, it checks to see if a file exists (full filename)... If My.Computer.FileSystem.FileExists("C:\Temp\Test.cfg") Then MsgBox("File found.") Else MsgBox("File not found.") End If ...But what about if part…
Muhnamana
  • 1,014
  • 13
  • 34
  • 57
5
votes
3 answers

check if the file is of a certain type

I want to validate if all the files in a directory are of a certain type. What I did so far is. private static final String[] IMAGE_EXTS = { "jpg", "jpeg" }; private void validateFolderPath(String folderPath, final String[] ext) { File dir…
yesh
  • 2,052
  • 4
  • 28
  • 51