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

283
Visualizações
Setting input image default value

I want to set input tag default value to "http://websamplenow.com/30/userprofile/images/avatar.jpg"

background-image is useless.. I am using django and bootstrap.

My template.

{% extends 'base.html' %}

{% block content %}
<style>
textarea.form-control {
  height: 500%;
}
</style>

<div class="container" style="padding-top: 60px;">
    <h1 class="page-header">Edit Profile</h1>
    <div class="row">
        <form class="form-horizontal" method="post" enctype="multipart/form-data">
            {% csrf_token %}
        <!-- left column -->
            <div class="col-md-2 hidden-xs">
                <img id="image" class="img-responsive img-thumbnail" />
                <input name="image" id="files" type="file" class="text-center well-xs">
            </div>

        <!-- edit form column -->
            <div class="col-md-8 col-sm-6 col-xs-12 personal-info">
                <div class="form-group">
                    <label class="col-md-3 control-label"></label>
                    <div class="col-md-8">
                        <button class="btn btn-primary" type="submit">submit</button>
                        <span></span>
                        <a class="btn btn-default" href="{% url 'soldier-list' %}">&nbsp;&nbsp;cancel&nbsp;&nbsp;</a>
                    </div>
                </div>
            </div>
        </form>
    </div>
</div>


<script>
	document.getElementById("files").onchange = function () {
    var reader = new FileReader();
    reader.onload = function (e) {
        // get loaded data and render thumbnail.
        document.getElementById("image").src = e.target.result;
    };
    // read the image file as a data URL.
    reader.readAsDataURL(this.files[0]);
};
</script>
{% endblock %}

Please help me. Thanks.

over 4 years ago · Santiago Trujillo
1 Respostas
Responde à pergunta

0

You can't, for security reasons. If you could, you could create invisible file inputs on the page and assign them default values and possibly upload images unknowingly from the client.

Check out this answer on stackoverflow: How to set a value to a file input in HTML?

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