Fetch names from all files in a folder?

Asked

Viewed 27 times

0

I have a code made to fetch images but it’s a little more complicated than that.

$("#publi_not").change(function(){
    var p = 0;
    var r = 1;
    var val = $(this).val();
    var valor = $('#publi_not option[value="'+val+'"]').html();
    var n_pub = $('#publi_not option[value="'+val+'"]').data("numero")+1;
    var balance = $("#imagens_not").get(0).files.length;
    var pub_txt = $("#text_img").val();
    var pub = pub_txt;
    for(t=1;t<=balance;t++){
        if(n_pub<=t){
            r=1;
        }
        $(".images"+p+" .images_pub").html("<img src='pubs/"+valor+"/"+valor+r+".png' style='width:100%' /><div class='altera' style='margin-top:-20px;top:0;left:2px;position:absolute;color:white;'><small><small><small><b>"+pub+"</b></small></small></small></div>");
        p++;
        r++;
    }
});

The code is executed when I change the value in a select which will then add a div below depending on what is selected.

Okay, here’s the problem. I recently created a table (because the previous one was based on tests) that has the names of the images but how do I show the files?

I thought I’d just read the files from a folder with the name of the ad but I couldn’t even get that.

  • How is the path of your images? pubs/um_valor/um_valor_0.png, pubs/um_valor/um_valor_1.png, etc.?

  • That’s how it is now, but the way is pubs/NOME_PRINCIPAL/NOME_DA_IMAGEM because before the images were all numbered because they were test

  • So the names of the images are not predictable? Javascript will not be able to read the files that are in the folder because it runs on the client side in the browser. Can you show some real image paths? To see if there is any logic in javascript that you can use

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.