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

549
Visualizações
i want to upload images on imgbb with custom name

i want to upload images on imgbb with API with custom name.
My current HTML was:

<input type="text" name="img_name" id="name" accept="text/*">
<input type="file" id="input_img" accept="image/*">
<input type="submit" value="Send" onclick="fileChange()">

and My current JS was:

function fileChange(){
  var file = document.getElementById('input_img');
  var imgname = document.getElementById('name');
  var form = new FormData();
  form.append("image", file.files[0])

    
    var settings = {
      "url": "https://api.imgbb.com/1/upload?key=(API CODE)",
      "method": "POST",
      "timeout": 0,
      "processData": false,
      "mimeType": "multipart/form-data",
      "contentType": false,
      "data": form
    };
    
    
    $.ajax(settings).done(function (response) {
      console.log(response);
      var jx = JSON.parse(response);
      console.log(jx.data.url);
    
    
    });
}

when i upload image it will upload with the image default name but i want to give it custom name.
Current Result:
https://i.stack.imgur.com/bbKZb.jpg

What I want:
https://i.stack.imgur.com/9BesZ.jpg

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

0

According to the api document.

name (optional) The name of the file, this is automatically detected if uploading a file with a POST and multipart / form-data

You should add &name=yourName to the url to chanage upload name

var settings = {
  "url": "https://api.imgbb.com/1/upload?key=(API CODE)&name="+ $('#name').val(),
  "method": "POST",
  "timeout": 0,
  "processData": false,
  "mimeType": "multipart/form-data",
  "contentType": false,
  "data": form
};
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