file-exists

file_exists not working with localhost URL

无人久伴 提交于 2019-12-02 18:17:15
问题 I have this piece of code in PHP: if (file_exists($_POST['current_folder'])) { //do something } But file_exists always returns false. The value passed to the function is: echo $_POST['current_folder']); //This prints: http://localhost/wordpress/wp-content/music I also tried with different folders on the localhost. The function always returns false. I also tried is_dir() . But even this function returns false with the above URL. There are many related questions on Stack Overflow. But most of

How to check whether file exists in Qt in c++

拜拜、爱过 提交于 2019-12-02 16:04:24
How do I check whether a file exists in a given path or not in Qt? My current code is below: QFile Fout("/Users/Hans/Desktop/result.txt"); if(!Fout.exists()) { eh.handleError(8); } else { // ...... } But when I run the code it is not giving the error message specified in handleError even though the file I mentioned in the path does not exist. (TL;DR at the bottom) I would use the QFileInfo -class ( docs ) - this is exactly what it is made for: The QFileInfo class provides system-independent file information. QFileInfo provides information about a file's name and position (path) in the file

file_exists not working with localhost URL

送分小仙女□ 提交于 2019-12-02 13:08:30
I have this piece of code in PHP: if (file_exists($_POST['current_folder'])) { //do something } But file_exists always returns false. The value passed to the function is: echo $_POST['current_folder']); //This prints: http://localhost/wordpress/wp-content/music I also tried with different folders on the localhost. The function always returns false. I also tried is_dir() . But even this function returns false with the above URL. There are many related questions on Stack Overflow. But most of them suggest that file_exists only works with relative URLs. But from this link it is clear that http://

Case sensitive file extension and existence checking

吃可爱长大的小学妹 提交于 2019-12-02 10:14:28
问题 I need to check whether or not a file exists. Which can be accomplished by File#exists() method. But this existence checking is case sensitive. I mean if I have a file name some_image_file.jpg in code but if physically the file is some_image_file.JPG then this method says that the file doesn't exists. How can I check the file existence with case insensitivity to the extension and get the actual file name? In my scenario, I have a excel file. Each row contains metadata for files and the

Why does PHP think this folder doesn't exist?

戏子无情 提交于 2019-12-02 09:31:21
I'm having trouble creating a folder and writing into it. if(file_exists("helloFolder") || is_dir("helloFolder")){ echo "folder already exists"; } else { echo "no folder, creating"; mkdir("helloFolder", 0755); } This returns "no folder, creating" even when the folder already exists. Then I get this error: Warning: mkdir() [function.mkdir]: No such file or directory in script.php on line 18 Warning: file_put_contents(/filename.txt) [function.file-put-contents]: failed to open stream: Permission denied in script.php on line 58 What is very strange is that I call three separate scripts that do

Case sensitive file extension and existence checking

五迷三道 提交于 2019-12-02 04:39:18
I need to check whether or not a file exists. Which can be accomplished by File#exists() method. But this existence checking is case sensitive. I mean if I have a file name some_image_file.jpg in code but if physically the file is some_image_file.JPG then this method says that the file doesn't exists. How can I check the file existence with case insensitivity to the extension and get the actual file name? In my scenario, I have a excel file. Each row contains metadata for files and the filename. In some cases I have only the filename or other cases I can have full path. I am denoting a row as

Check if file exists in C++

牧云@^-^@ 提交于 2019-12-01 21:13:42
问题 I'm very very new to C++. In my current project I already included #include <iostream> #include <Windows.h> #include <TlHelp32.h> 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 directory of my program. So what would be the best way for me to do that? 回答1: So, assuming it's OK to simply check that the file with the right name EXISTS in the same directory: #include <fstream> ... void check_if_dll_exists() { std::ifstream dllfile(".\

In C, checking for existence of file with name matching a pattern

送分小仙女□ 提交于 2019-12-01 12:34:38
I've seen a few methods for checking the existence of a file in C. However, everything I've seen works for a specific file name. I would like to check for any file that matches a particular pattern. For instance, maybe the pattern is "lockfile*" and "lockfileA", "lockfile.txt", or "lockfile.abc" would register in the check. The way I am doing this currently is to open the directory with opendir() then cycle through readdir() and try to match the pattern with name of each file returned. It works, but I sure would like a more compact way to do this. Any ideas? You can use glob(3) (standardized

VBScript to move file with wildcard, if it exists

落花浮王杯 提交于 2019-12-01 08:48:05
I am attempting to create a script that checks for the existence of archived eventlog files and, if any files exist, moves them to another folder. Running this script does nothing and gives no errors. I believe the wildcard in the If statement is what is giving me issues. I am new to vbscript, and scripting in general, and would appreciate some advice. Set fso = CreateObject("Scripting.FileSystemObject") If (fso.FileExists("d:\eventlogs\Archive*.evtx")) Then FSO.CopyFile "d:\eventlogs\Archive*.evtx" , "d:\eventlogs\archive\" FSO.Deletefile "d:\eventlogs\archive*.evtx" End if Ahmad El-Hoss You

PHP: file_exists vs stream_resolve_include_path - What Performs Better?

筅森魡賤 提交于 2019-12-01 06:19:17
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 systems, etc). It got me wondering if anybody out there has done any benchmark testing on which of these is a better option, for both page load time, server performance and memory usage. I could not find anything here at SO that addressed this issue so figured it would be time for us to do so. I have done a little benchmark, but before results, let's