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

551
Visualizações
Is it possible for another element to act as a proxy for a file input in a web form?

I want to be able to drag a file onto any HTML Element and have it behave as if it was dragged onto a file input.

I can sort of do it with something like this:

<label>
    <input type="file">
</label>

… and use CSS to increase the label and hide the file input:

label {
    display: block;
    width: 200px;
    height: 100px;
}
input[type="file"] {
    box-sizing: border-box;
    width: 100%;
    height: 100%;
    opacity: 0;
}

but that isn’t very flexible.

I have tried using using a different element, which I would prefer, and JavaScript’s drop event and the eventTransfer object. I can get the file data, but can’t add it to the file input.

Other solutions tend to us Ajax and send the file directly or to some sort of holding area, but I would like to know whether it is possible to do simply with the file input.

about 4 years ago · Juan Pablo Isaza
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