Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Request object return {} #14

Closed
dexmendonca opened this issue Jul 21, 2017 · 3 comments
Closed

Request object return {} #14

dexmendonca opened this issue Jul 21, 2017 · 3 comments
Labels

Comments

@dexmendonca
Copy link

This is my form:

<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport"
          content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>
<body>
<form action="/" method="post" enctype="multipart/form-data">
    <input type="file" name="img" id="img">
     <input type="hidden" name="_token" value="{{ csrfToken }}">

    <input type="submit" value="Submit">
</form>
</body>
</html>

and this is my route.js


Route.get('/', function(req, res) {
    res.view('index', { csrfToken: req.csrfToken() });
});
Route.post('/', { uses: function(req, res) {
    res.send(req.input.all());
}});

But, when I submit the form, the json output is {}
captura de tela de 2017-07-21 02-04-00

Can you help me?

@harishanchu
Copy link
Member

Have you added any middleware to parse multipart requests.

Quorra is configured with bodyparser middleware by default which allows to parse four types of request data: JSON, url-encoded, text and raw.

If you want to parse multipart form data you have to add a multipart middleware like multer or busyboy.

Here is the documentation on adding custom middleware to you Quorra application: https://quorrajs.org/docs/1.0.0/getting-started/middleware.html#custom-middleware

PS: Please use our gitter chat room for discussions. Github issues are specifically for registering bugs and requesting features.

@harishanchu
Copy link
Member

FYI Handling file uploads with QuorraJS

@dexmendonca
Copy link
Author

Thank you ! 😄

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants