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

173
Visualizações
Not receiving correctly multipart form data with PHP Klein

I have a big issue with receiving data from multipart form request sent by my reactJS front-end to the PHP api handled with Klein. I just tried to send with Javascript this fetch request

 const data = new FormData();
    data.append('sourceId', sourceId);
    data.append('customerId', customerId);
    const resp = await fetch(URL_CREATE_DOC, {
      method: 'POST',
      body: data,
      headers: {
        'Content-Type': 'multipart/form-data; boundary=stackoverflowrocks',
      }

and then to receive in my PHP Api with this

var_dump($request->files()->all());

but there's no data ! In the header, I see that the data is well sent by the front and when I make a var_dump($request->server()), I see the CONTENT_LENGHT changing if I send files. I think I don't do something well but how can I get the data from the multipart request ?

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

According to the readme:

$request->
    id($hash = true)                    // Get a unique ID for the request
    paramsGet()                         // Return the GET parameter collection
    paramsPost()                        // Return the POST parameter collection
    paramsNamed()                       // Return the named parameter collection
    cookies()                           // Return the cookies collection
    server()                            // Return the server collection
    headers()                           // Return the headers collection
    files()                             // Return the files collection
    body()                              // Get the request body
    params()                            // Return all parameters
    params($mask = null)                // Return all parameters that match the mask array - extract() friendly
    param($key, $default = null)        // Get a request parameter (get, post, named)

files() is exclusively for uploaded files, which you don't seem to have; your values can be found in POST data, which means any one of paramsPost(), params() or param($name) would be correct.

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