简体   繁体   English

表单编码苗条框架

[英]form enctype slim framework

Hello so I currently have a working form for submission in slim framework. 您好,所以我目前有一个可以在苗条框架中提交的工作表格。 This is how my html looks like: 这就是我的html的样子:

<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 . 现在,如果我想在enctype='multipart/form-data'添加enctype='multipart/form-data' ,并在表单内部添加另一个<input type="file" name="filename"> ,则当我尝试提交时会出现Undefined index: txt_fname错误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(); 您可以尝试使用Slim内置功能来获取所有Post参数: $request->post();

If your file will not shown there you may need to use $_FILES to handle that file upload. 如果您的文件没有显示在那里,您可能需要使用$_FILES来处理该文件上载。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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