Monday, March 6, 2017

Counting the number of files in a directory in laravel [duplicate]

This question already has an answer here:

I'm developing a website for showcasing few products and I have stored all my images in a public/images/ now I want to take it step by step. So I just want to count the number of images in the folder and display it on the screen like,If the user click on a particular product it should display x number of product available and then it should display all the images,the displaying part is not necessary for now. I just was to count and display in the screen.

I'm using xampp for testing locally and my project is in Laravel 5.0

This is what I have tried so far in ajax

 var dir = 'public/images/homePage/';
    var fileextension = ".jpg";
    $.ajax({
        type: 'GET'
        , url: dir
        , dataType: 'text'
        , success: function (data) {
            console.log('able to access');
        }
        , error: function (req, status, err) {
            console.log("error" + err + status);
        }
    });

I am just getting 404 Not Found error,I have no idea about what is wrong.



via this.Believer

Advertisement