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

190
Visualizações
read file with php that sent by axios with content-type : image/jpeg

hi i create a simple program when input type file change, file upload to the server and get it by php but in php server doesn't return any data and $_FILES is empty

my form content type is image jpeg and shoudn't change

and request type is put

and never use formdata

here my code:

 document.getElementById('filexxx').addEventListener('change',function(e){
        var formdata = new FormData();

        window.temp = e.target.files[0];
        console.log(e.target.files[0]);
        //https://divar.ir/upload_s3/temp/xxx.jpg
        axios.put('http://localhost:8080/test.php', e.target.files[0], {
                    withToken: 'eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1c2VyIjoiMDkzNzUyMTA4NTciLCJleHAiOjE2MzY4Nzk1MDcuMDY3MTI2LCJ2ZXJpZmllZF90aW1lIjoxNjM1NTgzNTA3LjA2NzEzMSwidXNlci10eXBlIjoicGVyc29uYWwiLCJ1c2VyLXR5cGUtZmEiOiJcdTA2N2VcdTA2NDZcdTA2NDQgXHUwNjM0XHUwNjJlXHUwNjM1XHUwNmNjIn0.P0sfbX9pg_jOpX2zhf2H5YmIrBdXo-7NSq2ayaJIoQo',
                    headers: {
                        "Content-Type": "image/jpeg"
                    },
                    timeout: null
                })
    });

and my server side code in test.php

<?php
  var_dump($_REQUEST);
  var_dump($_FILES);
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