Reading images from an asset folder in web export

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Panagiotis Halatsako

I am trying to make a simple quiz game (godot v3.2.1 stable) with some jpeg photos located in res://photos/
I have used the following code to get the images to a var called movie_titles (it’s a movie quiz!):

func dir_contents(path):
	JavaScript.eval("console.log('reading from path:"+path+"')")
	var dir = Directory.new()
	if dir.open(path) == OK:
		dir.list_dir_begin()
		var file_name = dir.get_next()
		while file_name != "":
			if dir.current_is_dir():
				#print("Found directory: " + file_name)
				pass
			else:
				#print("Found file: " + (path+file_name).get_extension())
				if (path+file_name).get_extension() == "jpg":
					JavaScript.eval("console.log('"+path+file_name+"')")
					movie_titles.append(path+file_name)
			file_name = dir.get_next()
	else:
		print("An error occurred when trying to access the path.")
		JavaScript.eval("console.log('An error occurred when trying to access the path.')")
	
	emit_signal("titles_read")

My problem is that when I export this to html5 I get that the size of the movie_titles is 0.

I get this both from the built in test webserver and in python3’s web server. Is there something I need to do to html5 export?

:bust_in_silhouette: Reply From: Panagiotis Halatsako

Actually this is answered before:https://forum.godotengine.org/59637/cannot-traverse-asset-directory-in-android?show=59637#q59637

It seems that the jpeg/image files are moved into a special .import folder and the actual forlder has only jpg.import extensions. Looking at the above answer I was able to complete my solution and load dynamically what I wanted.