0
I’m having a problem uploading images from a file(folder) to the web page. When you start the page, only two images are loaded, the others fail! I’m using Javascript and Jquery, css/html.
var $galery = $('.galery');
function fetchArticles(contents){
for(var i= 0 ; i <contents.length ; i ++){
console.log(contents[i].images[0].id);
$galery.append('<h2>'+contents[i].name+'</h2>');
$galery.append('<p>'+contents[i].texto+'</p><br>');
$galery.append('<p>'+contents[i].images[0].id+'</p><br>');
var folder = "/static/img/ContentPhotos/";
$galery.append('<img src='+folder+contents[i].images[0].name+' width="300" height="250"></img>');
}
}
seeing only the code that you made available, apparently it is correct, you are passing the name of the files correctly? try using encodeURI(Folder+Contents[i].images[0].name) to see if it solves
– Vinicius Dutra
My code:
<img src="encodeURI('+folder+')" width="300" height="250" />
Result: <img src="encodeURI(/Static/img/Contentphotos/e2e000f4-7d75-4ef3-b825-a0d00c7cf535.jpg)" width="300" height="250" />– Jairo Ramos
With my code the page loads the first two images, the remaining ones that start to come out broken!
– Jairo Ramos
And yes Vinicius, the names are being passed correctly. I’m afraid how this is happening in a loop of images that’s inside another loop of content, and it’s disfigured!
– Jairo Ramos