ESP8266WebServer file download problem

My siple test program uses a ESP8285 in standalone mode as web server. It makes a web page with a download button, and sends a file to the client on click. (I am about to write a data logger later)
It is working, and on PC it downloads the .jpg file. On Android mobile it downloads too, but with additional extension: mainecoon.jpg.phps, otherwise it's the correct image file too.

I am not familiar with http protocols, tried to copy-paste parts from samples.
What is the problem?

This line creates the download button on the web page:
... ptr += "<a href='/download'><button>Download</button></a>";

And this is the code for sending the file:
server.on("/download", handle_download);

void handle_download()
{
  Serial.println("download");
  file_download("mainecoon.jpg");
}

void file_download(String filename) {
  File download = SPIFFS.open("/" + filename, "r");
  if (download) {
    server.sendHeader("Content-Type", "text/text");
    server.sendHeader("Content-Disposition", "attachment; filename=" + filename);
    server.sendHeader("Connection", "close");
    server.streamFile(download, "application/octet-stream");
    download.close();
  } else ReportFileNotPresent("download");
}`Preformatted text`

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.