Hi, I´m just trying to run a web server on my esp32-cam with index.html, style.css loaded from SPIFFS filesystem. my scketch load right, but y cant read the index.html file.
Anyone have experience with this board?
Any help will be greast
Hi.
When you say you can’t read the index.html file, what happens?
Can you provide more details?
Regards,
Sara
Hi Sara,
I get a HTTP ERROR 404 from the browser when I try to access to the web server, I´ve checked that the 80 port is up.
I did another test trying to read a file from the sppfs file system and.. the behaviour is odd. I inserted this code (below) after sppfs is mounted and regardless the file I try to open never give me an error, also never can read it.
Cheers
File file = SPIFFS.open("/text.txt");
if(!file)
{
Serial.println("Failed to open file for reading");
return;
}
Serial.println("File Content:");
while(file.available())
{
Serial.write(file.read());
}
file.close();
Hi.
When we’re dealing with files from SPIFFS, usually the 404 error means that:
- the file was not successfully uploaded to SPIFFS
- the file doesn’t have the right name
- when handling the request from files, you’re not passing the right filename
That snippet of text doesn’t actually check if the file exists.
Use the following snippet instead:
bool fileexists = SPIFFS.exists(dataPath); //replace with the file datapath
Serial.print(fileexists);
if(!fileexists) {
Serial.println("File doens't exist");
}
else {
Serial.println("File already exists");
}
I hope this helps.
Regards,
Sara
Hi,
I resolved an issue with the uploaded files, that was the problem. Thanks Sara
The snippet I pasted before yours made me go through the wrong way. Thanks again.
Cheers
Hi,
I resolved an issue with the uploaded files, that was the problem. Thanks Sara
The snippet I pasted before yours made me go through the wrong way. Thanks again.
Cheers