Laravel – How to count number of files in folder and remove all files in folder example?

Laravel – How to count number of files in folder and remove all files in folder example?

In this post we will give you information about Laravel – How to count number of files in folder and remove all files in folder example?. Hear we will give you detail about Laravel – How to count number of files in folder and remove all files in folder example?And how to use it also give you demo for it if it is necessary.

you are working on laravel framwork and you want to count how many image or files in folder and print of front then you can do with laravel “File” class.you can also count in core PHP by using glob() but if you are working on laravel then you have to use ‘File’ class library and it is easy and more flexible to use.

If you also want to remove all the files Or images in specific folder then you can delete by using “File” class function. sometimes we need to delete files in the folder. that way:

use Input;

use File;

class HomeController extends AdminController

{

public function countImages() {

$files = File::files(public_path('textPrintImage'));

$filecount = 0;

if ($files !== false) {

$filecount = count($files);

}

return $filecount;

}

public function removeImages() {

File::cleanDirectory(public_path('textPrintImage'));

return back();

}

}

Try this…

Hope this code and post will helped you for implement Laravel – How to count number of files in folder and remove all files in folder example?. if you need any help or any feedback give it in comment section or you have good idea about this post you can give it comment section. Your comment will help us for help you more and improve us. we will give you this type of more interesting post in featured also so, For more interesting post and code Keep reading our blogs

For More Info See :: laravel And github

Leave a Comment

Your email address will not be published. Required fields are marked *

9  +  1  =  

We're accepting well-written guest posts and this is a great opportunity to collaborate : Contact US