Problem with ESP8266 Web Server [Fixed]

My suspicion is that you are sizing temp[] for the string length but not leaving room for the all important null terminator. So when you send the string to the client it doesn't know where the end of the string is and continues on into some random area of memory, thus the gibberish. Your Serial output works differently because that for loop ensures that it will stop at the end of the string. I suspect if you had simply done Serial.print(temp) you would see the same result as what the client received.

Try the following code that ensures you get a null terminator:

void handleRoot() {
  digitalWrite(led, 1);
  String path = "/index.html";

  File f = SPIFFS.open(path, "r");
  if(!f) {
    Serial.print("Failed to open File: '");
    Serial.print(path);
    Serial.println("'");
    Serial.println("");
  }

  int charAmt = f.size();
  char temp[charAmt+1];
  f.readBytes(temp, charAmt);
  temp[charAmt] = 0;  // Add null terminator

  server.send(200, "text/html", temp);
  digitalWrite(led, 0);

  Serial.println(charAmt);
  for(int i = 0; i < charAmt; i++) {
    Serial.print(temp[i]);
  }
}