Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

548
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda