Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

119
Visualizações
Downloading files in JavaScript on mobile Chrome on iOS

I have a JavaScript program that converts a canvas to an image and downloads it as a jpg file. It works on desktop Chrome and Safari and iOS Safari, but on iOS Chrome the filename is not used and the downloaded file is simply called "document". If I rename it to "document.jpg" manually I can see that the data is fine.

How do I get iOS Chrome to save the file using a given name?

Here is the Javascript code I have written:

    var dataURL = capture.toDataURL('image/jpeg', 0.8);
    // console.log(dataURL);
    var link = document.createElement("a");
    link.href = dataURL;
    link.download = "elfie.jpg";
    document.body.appendChild(link);
    link.click();
    document.body.removeChild(link);

Note that I set the mime type in the toDataURL command and the downloaded filename in the link.download command. As I say, iOS Chome seems to ignore the filename and just calls the it "document".

Thanks for your help.

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

As of Q1 2022, I believe this is currently impossible.

See my answer here for details.

The short version is: writing files to disk on mobile browsers sucks very badly for almost all major browsers on the major mobile platforms.


Note: I would have preferred to handle this by voting to close this question as a duplicate of the question I linked, but my answer there has not been accepted, so StackOverflow won't let me do that.

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda