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

201
Visualizações
How to detect image upload through api in input feild of htm?

I have a project where users have their profile and values are coming from API.I am using Django as a language. So when I add my profile photo it is working fine with the current code.And when I go to edit page of the same user it display my current image and when I again hit the save button it detect no image.

my html with api value in src:-

<div class="main-img-preview margin_bottom10">                              
    <img class="thumbnails img-preview" src="{% if result_data_for_editing.profileImage.mediaPath != None %}{{ result_data_for_editing.profileImage.mediaPath }}{% else %}{{ '../assets/images/default-user-image.png' }}{% endif %}"
                                             title="Preview Logo" accept="image/*" >
</div>
<div class="input-group">
    <div class="input-group-btn">
        <div class="fileUpload btn btn_teal btn_raised text-uppercase fake-shadow">
            <span>Browse</span>
            <input id="logo-id" name="media" type="file"
                   class="attachment_upload" required="">
        </div>
    </div>
</div>

my script is this:-

$(document).ready(function () {
    var brand = document.getElementById('logo-id');
    brand.className = 'attachment_upload';
    brand.onchange = function () {
        document.getElementById('fakeUploadLogo').value = this.value.substring();
    };
    function readURL(input) {
        if (input.files && input.files[0]) {
            var reader = new FileReader();
            reader.onload = function (e) {
                $('.img-preview').attr('src', e.target.result);
            };
            reader.readAsDataURL(input.files[0]);
        }
    }

    $("#logo-id").change(function () {
        readURL(this);
    });
});

How can I detect the image from API into my input field. Please ignore grammatical mistakes if their are any. Thanks in advance

over 4 years ago · Santiago Trujillo
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