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
7
votes
2 answers

unlink/file_exists and file not found

I have this code in my application, often run in race condition by severals users of my application clearstatcache(TRUE, $filepath); if(file_exists($filepath)) unlink($filepath); But, for this line of code, I still have severals errors each day…
Cédric Girard
  • 3,358
  • 7
  • 37
  • 52
7
votes
3 answers

Twig check if file exists

Hello so I am using slim framework and twig, and here is my current code in php: $filename = '/path/to/foo.txt'; if (file_exists($filename)) { echo "The file $filename exists"; } else { echo "The file $filename does not exist"; } Now I want…
wobsoriano
  • 12,348
  • 24
  • 92
  • 162
7
votes
5 answers

Check if URL exists or not on Server

This is my code which I am using to verify, URL exists or not on Server, but always getting not exist however link is alive Where I am doing mistake in my code, why I am always getting "doesnot exist !" public class MainActivity extends Activity { …
Sophie
  • 2,594
  • 10
  • 41
  • 75
7
votes
4 answers

how can I find whether there is any txt file in a directory or not with Python

I would like to find that whether there is any file exists in a specific directory or not with using python. Something like this; if os.path.exists('*.txt'): # true --> do something else: # false --> do something
erolkaya84
  • 1,769
  • 21
  • 28
7
votes
4 answers

Can MySQL check that file exists?

I have a table that holds relative paths to real files on HDD. for example: SELECT * FROM images --> id | path 1 | /files/1.jpg 2 | /files/2.jpg Can I create a query to select all records pointing to non-existent files? I need to check it by…
WindBridges
  • 693
  • 2
  • 11
  • 23
7
votes
2 answers

Check if a file exists in Yii

I am creating a bunch of modules that all extend a base module. However, some actions need to override the base view. In that case, I'd like to check if the new module has a view in its structure. If it does, use that view, and otherwise use the…
Sergi Juanola
  • 6,531
  • 8
  • 56
  • 93
7
votes
3 answers

PHP file_exists but rename fails "No such file or directory..."?

Thinking creation of the file in question lags a bit behind the offending function, I tried running a while loop to buy a little time before calling rename. $no_file = 1; while($no_file && $no_file < 300) { // generation of Worksheet.xls may…
WallabyKid
  • 503
  • 2
  • 5
  • 16
6
votes
3 answers

PHP file_exists returns false but the file does exist

I have seen several similar questions, but no answer worked in my situation, except that it probably has something to do with permissions. A PHP script served by Apache tells me unable to open database file. When I print the path to that file, it…
JulienD
  • 7,102
  • 9
  • 50
  • 84
6
votes
3 answers

How to check that file exists inside a zip archive?

How to check that file exists inside a zip archive? For example, check whether app.apk contains classes.dex. I want to find a solution that uses Java NIO.2 Path and without extracting the whole archive if possible. I've tried and it didn't…
naXa stands with Ukraine
  • 35,493
  • 19
  • 190
  • 259
6
votes
3 answers

Checking if a php process is already running

I'm trying to check if a process is already running by using a temporal file demo.lock: demo.php:
Borgtex
  • 3,235
  • 1
  • 19
  • 28
6
votes
0 answers

xcode error when download files from sandbox

I save the files as .txt files using the following code: FILE* file; file = NULL; const char *filename = [newFilePath UTF8String]; file = fopen(filename, "wb"); However, when I download them from the Sandbox in Organizer, a error…
6
votes
2 answers

Does include() use file_exists()'s cache?

The question is quite simple: When it comes to touching the disk, are these two examples equal, or does scenario #2 touch the disk twice? Scenario #1 include '/path/to/file.php'; Scenario #2 if (file_exists('/path/to/file.php')) include…
Sverri M. Olsen
  • 13,055
  • 3
  • 36
  • 52
6
votes
2 answers

check file existence from root

I tried the following code to check existence of file in root. if($res['profile_picture']!="" && file_exists("images/".$res['users_id']."/thumnails/".$res['profile_picture'])){ …
Mohit Tripathi
  • 127
  • 1
  • 7
5
votes
8 answers

php file_exists is returning false even if file exist on my linux

This question has been asked many times, but none of the answers I found helped me. I am trying to get php file_exists() to work. The only scenario when it works is when the php-file is in the same directory as the file to use file_exist() on and…
Nicsoft
  • 3,644
  • 9
  • 41
  • 70
5
votes
5 answers

check if file exist in folder

My script: $secret = check_input($_GET['secret']); if(isset($_POST['register'])) { if (isset($secret) || !empty($secret)) { if (file_exists(ROOT . '/intl/codes/' . $secret)) { unlink(ROOT . '/intl/codes/' . $secret); …
ZeroSuf3r
  • 1,961
  • 8
  • 25
  • 36