File cannot be opened isuue with SPIFFS

727 views Asked by At

I would like to try SPIFFS for ESP8266. I installed the Data upload and everything seems ok, I dont know why I get a error message that the file cannot be opened.

enter image description here

enter image description here

Here is the code:

#include "FS.h"
 
void setup() 
{

  Serial.begin(115200);
  
  if(!SPIFFS.begin())
{

    Serial.println("An Error has occurred while mounting SPIFFS");

    return;

  }
  
  File file = SPIFFS.open("/example.txt", "r");

  if(!file){

    Serial.println("Failed to open file for reading");

    return;
  }
  
  Serial.println();

  Serial.println("File Content:");

  while(file.available()){

    Serial.write(file.read());

  }

  file.close();
 
}
 
void loop() {

}
0

There are 0 answers