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

213
Visualizações
Attach an image from url in form data in JS?

I am trying to make a POST request where an image file is required as part of the payload. If I had the file itself I could have used it as part of the FormData. But the problem is that the client only has the image url. Is it possible to retrieve the image from the url and attach it as part of the FormData?

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

0

Use the fetch API to download the image.

This will require the host of the image to grant you permission to access it using CORS.

Get a blob() from the fetch response.

Attach it to your FormData as if it were a file.


It is quite likely, especially if you don't have the co-operation of the person hosting the image, that it would be simpler to change the API you are making the POST request to so it can accept a URL instead of an image file. You can then use server side code to make the request.

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