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
4
votes
3 answers

Rename a file if same already exists

I'm trying to upload a file and rename it if it already exists. The way I want i to do is that when det same file uploads the name just adds 1, then 2, then 3, and so on. Example: If file "file" exists, the new file should be "file1", then the next…
Aromefraise
  • 45
  • 1
  • 1
  • 7
4
votes
3 answers

Objective-C. Create file at path which doesn't exist?

For example if I want to write file.txt into /folder1/folder2/folder3/ and noone of folders exists. Is it the only way to create them manually?
user2083364
  • 744
  • 1
  • 7
  • 20
4
votes
1 answer

When does file_exists() emit an E_WARNING?

I was wondering when does file_exists() return an E_WARNING??? in the manual it says Upon failure, an E_WARNING is emitted. Can you tell me a simple example of this, cause i couldn't come up with anything? UPDATE: so, if i try to check a file…
4
votes
2 answers

Check if file exists in C++

I'm very very new to C++. In my current project I already included #include #include #include and I just need to do a quick check in the very beginning of my main() to see if a required dll exists in the…
forivin
  • 59
  • 1
  • 1
  • 3
4
votes
1 answer

how to check file exist in php using only extension like (*.pdf)

$filename = '/www/test1/*.pdf'; if (file_exists($filename)) { echo "The file $filename exists"; } else { echo "The file $filename does not exist"; } I used above code but it checks for *.pdf file but not…
M Gaidhane
  • 531
  • 8
  • 29
4
votes
2 answers

Under Windows XP, with the C language: Checking if a file is open

In my application, written in C, under Windows-XP: how can I check if a file is already open by another application? One option is to rename the file, and to check if it was renamed. Another option is to open the file for appending. But these…
Nir S.
  • 53
  • 5
4
votes
3 answers

Wait until jquery ajax request is done and return value

I want to wait until ajax call complete and return the value. function isFileExists(url) { var res = false; $.ajax({ type: "GET", async: false, url: url, crossDomain: true, dataType: "script", …
Sagar
  • 259
  • 2
  • 3
  • 14
4
votes
5 answers

How to check a url exist or not in php

I want to check the url http://example.com/file.txt exist or not in php. How can I do it?
Mohammed H
  • 6,880
  • 16
  • 81
  • 127
4
votes
4 answers

PHP file_exists and special characters like Å Ø Æ on a Linux box

file_exists("file_å.txt"); Returns false while file is there. Is there any what to make *file_exists* to see the files with this kind of names? Thanks.
Aleksandr Makov
  • 2,820
  • 3
  • 37
  • 62
4
votes
5 answers

php check file name exist, rename the file

How do I check if file name exists, rename the file? for example, I upload a image 1086_002.jpg if the file exists, rename the file as 1086_0021.jpg and save, if 1086_0021.jpg is exist, rename 1086_00211.jpg and save , if 1086_00211.jpg is exist,…
yuli chika
  • 9,053
  • 20
  • 75
  • 122
3
votes
2 answers

PHP:is_file() and file_exists() return different results on same file

I am having an issue where file_exists returns false and is_file returns true. echo(getmygid()." = gid\n"); //501 echo(getmyuid()." = uid\n"); //501 echo(posix_getgid()." = pgid\n"); //501 echo(posix_getuid()." = puid\n");…
teotwawki
  • 65
  • 1
  • 7
3
votes
1 answer

PHP: clearstatcache() not working

My workflow is pretty simple: I delete a file I call clearstatcache() I save a new file I call clearstatcache() Still, at the end, is_file() returns false for a while before deciding to return true when i refresh 10sec later for example. It looks…
aaaaaa
  • 2,588
  • 3
  • 26
  • 31
3
votes
0 answers

file_exists() works when executed from phpunit, but not from web page

I have a file on a network shared location, and I want to check if it exists programmatically with PHP. When running from PhpUnit, it works fine. My minimal test is: public function testBackupFileExists () { $backup_pname =…
Brainless
  • 1,522
  • 1
  • 16
  • 30
3
votes
1 answer

os.path.isfile() returns false for file on linux smb network drive

My desktop computer is running Linux Mint 19.1. Another computer is running Linux Mint 18.3. Both computers are running Samba. I am trying to have my desktop python code check for a file on the other computer. In the Caja file manager it shows the…
LewTwo
  • 83
  • 8
3
votes
2 answers

Check if file exists with Laravel 5.5 Storage? Storage for Avatar

Based on this code: https://devdojo.com/episode/laravel-user-image I created the following code in order to upload an avatar and delete the old one. I'm tried to use Storage:Facade but I'm not sure if it is the right way. So let's look at my code…
Philipp Mochine
  • 4,351
  • 10
  • 36
  • 68