-->
Page 1 of 1

context of SPIFFS and server.send()

PostPosted: Sun Apr 22, 2018 4:34 pm
by Thomas Patrick
Hello.
What I am trying to do is load a file stored in SPIFFS into a web page generated from server.send()
i have a file index.htm in the root SPIFFS

<head><title>SPIFFS</title></head><body><div id=\"banner\"><img src=\"/images/image.jpg\" width=\"900\" height=\"295\" /></div> <div id=\"page\"></body></html>

and it shows the image stored in the SPIFFS and the page <title> shows SPIFFS
when i go to http://192.168.1.216/images/image.jpg (ip of the esp) it shows the image. every thing is fine
using the arduino code:

if(path.endsWith("/")) path += "index.htm";
if(path.endsWith(".src")) path = path.substring(0, path.lastIndexOf("."));
else if(path.endsWith(".htm")) dataType = "text/html";
else if(path.endsWith(".jpg")) dataType = "image/jpeg";

however when I create the html page using:

server.send(500, "text/html", "<head><title>SERVERSEND</title></head><body><div id=\"banner\"><img src=\"/images/image.jpg\" width=\"900\" height=\"295\" /></div> <div id=\"page\"></body></html>");

It takes me to the generated page with the title SERVERSEND and does not load the image stored in the SPIFFS.

and when i go to in my browser http://192.168.1.216/images/image.jpg the file is not found. so can any one help tell me whats going on? Can i not access SPIFFS once i use generate a page using server.send()

My goal is to generate a page using dynamic data from the esp using server.send() and manipulating assets stored in SPIFFS within the web page. I'm thinking that the root changes context with server.send() and once I use it i don't know where to find the SPIFFS files.

Thank you for any help. I have been running around in circles.