• Skip to main content
  • Skip to primary sidebar

RNTLab.com

The Ultimate Shortcut to Learn Electronics and Programming with Open Source Hardware and Software

  • Courses
  • Forum
    • Forum
    • Ask Question
  • Shop
  • Account
  • Blog
  • Login

SPIFFS on esp32-cam (webserver)

Q&A Forum › Category: Questions › SPIFFS on esp32-cam (webserver)
0 Vote Up Vote Down
Carlos Pascual asked 4 years ago

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

Question Tags: webserver
6 Answers
0 Vote Up Vote Down
Sara Santos Staff answered 4 years ago

Hi.
When you say you can’t read the index.html file, what happens?
Can you provide more details?
Regards,
Sara

0 Vote Up Vote Down
Carlos Pascual answered 4 years ago

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();

 
0 Vote Up Vote Down
Sara Santos Staff answered 4 years ago

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

0 Vote Up Vote Down
Carlos Pascual answered 4 years ago

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

0 Vote Up Vote Down
Carlos Pascual answered 4 years ago

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

0 Vote Up Vote Down
Sara Santos Staff answered 4 years ago

Hi.
Great!
I’m glad you solved the issue.
I’ll mark this issue as resolved. If you need further help, you just need to open a new question in our forum.
Regards,
Sara

Primary Sidebar

Login to Ask or Answer Questions

This Forum is private and it’s only available for members enrolled in our Courses.

Login »

Latest Course Updates

  • [New Edition] Build ESP32-CAM Projects eBook – 2nd Edition April 16, 2025
  • [eBook Updated] Learn ESP32 with Arduino IDE eBook – Version 3.2 April 16, 2025

You must be logged in to view this content.

Contact Support - Refunds - Privacy - Terms - MakerAdvisor.com - Member Login

Copyright © 2013-2025 · RandomNerdTutorials.com · All Rights Reserved

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.