Linked Questions
13 questions linked to/from How can I use PHP to check if a directory is empty?
-1
votes
1
answer
286
views
Php check if directory is empty [duplicate]
I am trying to use php to check if a directory is empty or not. I have seen a lot of similar questions but I have not been able to solve the problem. Namely, the following code always gives me the ...
0
votes
1
answer
257
views
How to show message if empty folder with scandir function [duplicate]
I would like to know how to show a small message when I use the Scandir function to show files of a folder,in place of a link if this folder is empty...
I show you the code :
<div class="...
7
votes
4
answers
14k
views
How to determine file exist in public directory for Laravel 5.2
I have some image files in public/image directory, so I want to determine if a file exist in that directory before I save a new file.
How to determine if a file exist?
4
votes
1
answer
4k
views
Remove only empty folders and subfolders in PHP
I've got a folder, filled with both empty and full folders.
I want to iterate over all of them, figure out if they are empty, and if so, remove them.
I've seen some questions that are appliccable, ...
1
vote
1
answer
2k
views
PHP: The fastest way to check if the directory is empty?
On Stack Overflow there are several answers to the question of how to check if the directory is empty, but which is the fastest, which way is the most effective?
Answer 1: https://stackoverflow.com/a/...
0
votes
1
answer
2k
views
How can I use Node.js to check if a directory is empty?
I asked this question for PHP a long time ago. The same applies for Node.js the code below seems a little slow when using in a loop - is there a way for writing this in pure Node.js vanilla JavaScript ...
1
vote
1
answer
946
views
How to check if folder has at least 1 file in php
I want to check if a folder has at least 1 file.
I am now using this to check if a folder is empty but this also checks if there is a subfolder in it.
if (count(glob($dir.'/*')) === 0 ) {}
And I ...
0
votes
2
answers
833
views
if folder is empty echo message, if not show all jpg files
im trying to echo all jpg image files in a folder.
it works, but i dont have the line to show an error that the folder is empty written properly. it shows a php script error instead,
another problem ...
0
votes
0
answers
601
views
PHP ZIP does not add an empty subfolder to the archive file [duplicate]
I am currently using the following piece of code to ZIP the current folder:
<?php
$rootPath = realpath('./');
$zip = new ZipArchive();
$zip->open('archive.zip', ZipArchive::CREATE | ...
1
vote
1
answer
479
views
In PHP v 5.6 how do I catch UnexpectedValueException?
I've reviewed a number of ways to determine that a directory is empty or not, and many indicate that $isDirEmpty = !(new \FilesystemIterator($dir))->valid(); is a good choice, except that the ...
-2
votes
1
answer
215
views
How to empty a directory in PHP except specific files
I'm creating a cron job that will autoflush the tmp directory everyday to make sure the tmp directory is not flooded with unwanted files.
However i want to delete all files and folders in the tmp ...
0
votes
2
answers
146
views
How to check,that there's nothing in the folder?
I would like to check if the folder is empty or not. I tried $files!=0 but it doesn't work,because the print_r($files); shows this: Array ( [0] => . [1] => .. ) How to write the right condition?
...
-2
votes
1
answer
69
views
Check if directory is empty, if not then show image inside, if yes then show a default image
I have a bit of a problem. I am putting up a profile picture on my system where the pictures are stored in a file and I'm calling it from the database. What I want to happen is this:
For person who ...