Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

170
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda