wobsoriano
wobsoriano

Reputation: 13434

form enctype slim framework

Hello so I currently have a working form for submission in slim framework. This is how my html looks like:

<form method="POST" action="/user/register-link">
<input type="text" name="txt_fname"> <br />
<input type="text" name="txt_lname"> <br />
<input type="submit">
</form>

And in my routes:

$request = \Slim\Slim::getInstance()->request();
parse_str($request->getBody(), $output);
echo $output['txt_fname'];
echo $output['txt_lname'];

All the code above is actually working. Now if I want to add enctype='multipart/form-data' in my form and another <input type="file" name="filename"> inside the form, when I try to submit I get an error of Undefined index: txt_fname. What is the possible mistake in my code?

Upvotes: 0

Views: 388

Answers (1)

danopz
danopz

Reputation: 3408

You could try to use Slim-built-in functionality to get all Post params: $request->post();

If your file will not shown there you may need to use $_FILES to handle that file upload.

Upvotes: 1

Related Questions