简体   繁体   中英

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?

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM