file-exists

Can MySQL check that file exists?

我与影子孤独终老i 提交于 2019-12-07 04:57:05
问题 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 MySql server exactly, without using an iteration in PHP-client. 回答1: I would go with a query like this: SELECT id, path, ISNULL(LOAD_FILE(path)) as not_exists FROM images HAVING not_exists = 1 The function LOAD_FILE tries to load the file as a string, and

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

余生长醉 提交于 2019-12-07 04:51:34
问题 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 while loop will be involved but I don't want it to be too resource intensive. What's a good way of doing this? 回答1: Basically you got it right while (!file_exists($filename)) sleep(1); print '<a href="'.$filename.'">download PDF</a>'; the sleep

How to tell if dynamically loaded image exists

痴心易碎 提交于 2019-12-06 14:52:02
I'm dynamically loading images from a different website into an asp.net ListView control like this: <ListView> <ItemTemplate> <img src='<%# string.Format("http://www.Website.com/Images/{0}", Eval("ImageName")) %>' /> Sometimes, the images don't exist and I need to change the src to a static path: src="/whatever/default.png". What is the fastest way I check if the image exists and update the src if it doesn't (any client side possibilities via jQuery)? The ListView is paged and could contain a result set of thousands of records, so I'd only like to check the images that are on the current page

PHP Phar - file_exists() issue

前提是你 提交于 2019-12-05 23:41:23
问题 My Phar script creates a new file with fwrite, which works fine, it creates the new file outside the phar, in the same directory as the phar file. But then when i use if(file_exists('file.php')) it doesn't pick it up. But then include and require do pick it up. Anyone know about this problem? Been testing and researching for a while a can't seem to find a solution. 回答1: At the PHAR's stub, you can use the __DIR__ magic constant to get the PHAR file's folder. With that in mind, you can simply

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

送分小仙女□ 提交于 2019-12-05 11:10:49
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 while loop will be involved but I don't want it to be too resource intensive. What's a good way of doing this? CSᵠ Basically you got it right while (!file_exists($filename)) sleep(1); print '<a href="'.$filename.'">download PDF</a>'; the sleep gives 1 second between checks so it won't stress your CPU for nothing this will do the work but you may

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

人盡茶涼 提交于 2019-12-05 01:51:06
问题 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 only using the file name (i.e. excluding the path). But it's not consequent behaviour, please see below. Som information: safe_mode=off no symlinks for directory 28 no whitespace in the file name All directories in /var/www/html/smic/upload/28/ has

How to detect if a file exist in a project folder?

六月ゝ 毕业季﹏ 提交于 2019-12-04 13:05:15
I am having a collection of images in my project folder. how to detect if a image exist in my project folder? I am using c#. Thanks. if (System.IO.File.Exists("pathtofile")) //it exist else //it does not exist EDITED MY ANSWER AFTER THE COMMENT OF THE QUESTION: I copied the code and changed the exits function, this should work string type = Path.GetExtension(filepath); string path = @"image/" + type + ".png"; //if(System.IO.File.Exists(path)) I forgot to use the full path if (System.IO.File.Exists(Path.Combine(Directory.GetCurrentDirectory(), path))) { return path; } else { return @"image

file_exists() or is_readable()

余生颓废 提交于 2019-12-04 09:55:51
问题 Which one should you use when you want to include a PHP file? if(file_exists($file) require "$file"; or if(is_readable($file) require "$file"; ? 回答1: file_exists() or is_readable() Which one should you use when you want to include a PHP file? This depends on if you want to know if only a file or a directory exists, or if either is fine, and if you need to check if readable or not. Sometimes you only care the file and/or directory exist, and don't need to read, sometimes you also need to read.

unlink/file_exists and file not found

自作多情 提交于 2019-12-04 06:23:18
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 like unlink(file): No such file or directory Server run Apache 2.2 and PHP 5.3.3. I know race problem, but think @ operator is just evil. I have first tried without any parameter for clearstatcache(), with the same error. How can I do it the correct way? you can try this if(@unlink($path)) { echo "Deleted file "; } else{ echo "File can't be deleted"; }

PHP Phar - file_exists() issue

耗尽温柔 提交于 2019-12-04 05:13:55
My Phar script creates a new file with fwrite, which works fine, it creates the new file outside the phar, in the same directory as the phar file. But then when i use if(file_exists('file.php')) it doesn't pick it up. But then include and require do pick it up. Anyone know about this problem? Been testing and researching for a while a can't seem to find a solution. At the PHAR's stub, you can use the __DIR__ magic constant to get the PHAR file's folder. With that in mind, you can simply use is_file(__DIR__ . DIRECTORY_SEPARATOR . $path); To check for a file's existence outside the PHAR. You