• <i id='1Tf3o'><tr id='1Tf3o'><dt id='1Tf3o'><q id='1Tf3o'><span id='1Tf3o'><b id='1Tf3o'><form id='1Tf3o'><ins id='1Tf3o'></ins><ul id='1Tf3o'></ul><sub id='1Tf3o'></sub></form><legend id='1Tf3o'></legend><bdo id='1Tf3o'><pre id='1Tf3o'><center id='1Tf3o'></center></pre></bdo></b><th id='1Tf3o'></th></span></q></dt></tr></i><div id='1Tf3o'><tfoot id='1Tf3o'></tfoot><dl id='1Tf3o'><fieldset id='1Tf3o'></fieldset></dl></div>

    • <bdo id='1Tf3o'></bdo><ul id='1Tf3o'></ul>
  • <small id='1Tf3o'></small><noframes id='1Tf3o'>

    <tfoot id='1Tf3o'></tfoot>
    1. <legend id='1Tf3o'><style id='1Tf3o'><dir id='1Tf3o'><q id='1Tf3o'></q></dir></style></legend>

      1. php http 请求内容原始数据 enctype=multipart/form-data

        php http request content raw data enctype=multipart/form-data(php http 请求内容原始数据 enctype=multipart/form-data)
            <tbody id='mWL76'></tbody>
            <bdo id='mWL76'></bdo><ul id='mWL76'></ul>
            <tfoot id='mWL76'></tfoot>

              <i id='mWL76'><tr id='mWL76'><dt id='mWL76'><q id='mWL76'><span id='mWL76'><b id='mWL76'><form id='mWL76'><ins id='mWL76'></ins><ul id='mWL76'></ul><sub id='mWL76'></sub></form><legend id='mWL76'></legend><bdo id='mWL76'><pre id='mWL76'><center id='mWL76'></center></pre></bdo></b><th id='mWL76'></th></span></q></dt></tr></i><div id='mWL76'><tfoot id='mWL76'></tfoot><dl id='mWL76'><fieldset id='mWL76'></fieldset></dl></div>

            • <small id='mWL76'></small><noframes id='mWL76'>

            • <legend id='mWL76'><style id='mWL76'><dir id='mWL76'><q id='mWL76'></q></dir></style></legend>
                  本文介绍了php http 请求内容原始数据 enctype=multipart/form-data的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我目前正在编写两个类:HttpRequest 和 HttpResponse.我想编写自己的 HTTP 类.

                  I'm currently coding two classes: HttpRequest and HttpResponse. I want to code my own HTTP classes.

                  我在使用带有 enctype=multipart/form-data 的表单的 POST 方法时遇到问题:我无法获取请求内容.

                  I'm encountering an issue with a POST method using a form with enctype=multipart/form-data: I can't get the request contents.

                  经过长时间的研究和搜索,我发现我必须使用 file_get_contents("php://input") 来获取请求内容.当我测试它时,我有一个空字符串 var_dump(file_get_contents("php://input")).

                  After a long research and searchs, I've found I have to use file_get_contents("php://input") to get the request content. When I test it, I have an empty string var_dump(file_get_contents("php://input")).

                  我无法访问服务器/php 配置.

                  I have no access to server/php configuration.

                  我正在使用以下代码进行测试:

                  I'm testing with the following code :

                  <?php
                  $input = file_get_contents('php://input');
                  var_dump($input);
                  ?>
                  <html>
                  <body>
                  <form action="./" method="post" enctype="multipart/form-data">
                      <label for="file">Filename:</label>
                      <input type="text" name="namen" id="nameid" /><br/>
                      <input type="file" name="file" id="file"><br>
                      <input type="file" name="file2" id="file2"><br>
                      <input type="submit" name="submit" value="Submit">
                  </form>
                  </body>
                  </html>
                  

                  提交后,我得到了这个结果:string(0) "".很明显,因为 php://input 不适用于 enctype="multipart/form-data" 表单.

                  And after submitting, I have this result : string(0) "". It's obvious because php://input doesn't work with enctype="multipart/form-data" forms.

                  我想要类似的东西:

                  -----------------------------19972703421793859182225487886
                  Content-Disposition: form-data; name="namen"
                  
                  ds
                  -----------------------------19972703421793859182225487886
                  Content-Disposition: form-data; name="file"; filename="toto.xml"
                  Content-Type: text/xml
                  
                  <?xml version="1.0" encoding="UTF-8"?>
                  <Toto></Toto>
                  
                  -----------------------------19972703421793859182225487886
                  Content-Disposition: form-data; name="file2"; filename=""
                  Content-Type: application/octet-stream
                  
                  
                  -----------------------------19972703421793859182225487886
                  Content-Disposition: form-data; name="submit"
                  
                  Submit
                  -----------------------------19972703421793859182225487886--
                  

                  它是否适用于任何请求方法?还是我错了?

                  Is a way it works for any request method ? Or am I wrong ?

                  推荐答案

                  我要在这里寻找一个显而易见的:为什么还要费心去尝试自己解析这个?数据在您的范围内,易于使用 $_POST[]/$_FILES[] ..

                  I'm going for the obvious one here: why even bother trying to parse this yourself? The data is within your range with the easy use of $_POST[] / $_FILES[] ..

                  您仍然可以围绕这些值构建您自己的类,而不是让您自己的类尝试完成与 php 编译器已经为您所做的相同的数据数组.

                  You can still build your own class around those values instead of having your own classes try to accomplish the same data array as the php-compiler already did for you.

                  为了给你一个有效的答案:我不知道有什么方法可以让你的 php://input 回来,因为它可能被 PHP 编译器读取,因此你在流的末尾(另外:它是只读的,因此可能无法将指针重置为流的开头).

                  In order to give you a valid answer: I don't know of a way to get your php://input back, as it is probably read by the PHP compiler and therefore you are at the end of the stream ( plus: it is read-only so there is probably no way to reset the pointer to the start of the stream ).

                  这篇关于php http 请求内容原始数据 enctype=multipart/form-data的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  DeepL的翻译效果还是很强大的,如果我们要用php实现DeepL翻译调用,该怎么办呢?以下是代码示例,希望能够帮到需要的朋友。 在这里需要注意,这个DeepL的账户和api申请比较难,不支持中国大陆申请,需要拥有香港或者海外信用卡才行,没账号的话,目前某宝可以
                  PHP通过phpspreadsheet导入Excel日期,导入系统后,全部变为了4开头的几位数字,这是为什么呢?原因很简单,将Excel的时间设置问文本,我们就能看到该日期本来的数值,上图对应的数值为: 要怎么解决呢?进行数据转换就行,这里可以封装方法,或者用第三方的
                  mediatemple - can#39;t send email using codeigniter(mediatemple - 无法使用 codeigniter 发送电子邮件)
                  Laravel Gmail Configuration Error(Laravel Gmail 配置错误)
                  Problem with using PHPMailer for SMTP(将 PHPMailer 用于 SMTP 的问题)
                  Issue on how to setup SMTP using PHPMailer in GoDaddy server(关于如何在 GoDaddy 服务器中使用 PHPMailer 设置 SMTP 的问题)

                    <small id='1Qb8c'></small><noframes id='1Qb8c'>

                      <bdo id='1Qb8c'></bdo><ul id='1Qb8c'></ul>
                          <tbody id='1Qb8c'></tbody>
                        <i id='1Qb8c'><tr id='1Qb8c'><dt id='1Qb8c'><q id='1Qb8c'><span id='1Qb8c'><b id='1Qb8c'><form id='1Qb8c'><ins id='1Qb8c'></ins><ul id='1Qb8c'></ul><sub id='1Qb8c'></sub></form><legend id='1Qb8c'></legend><bdo id='1Qb8c'><pre id='1Qb8c'><center id='1Qb8c'></center></pre></bdo></b><th id='1Qb8c'></th></span></q></dt></tr></i><div id='1Qb8c'><tfoot id='1Qb8c'></tfoot><dl id='1Qb8c'><fieldset id='1Qb8c'></fieldset></dl></div>
                      • <tfoot id='1Qb8c'></tfoot>
                        • <legend id='1Qb8c'><style id='1Qb8c'><dir id='1Qb8c'><q id='1Qb8c'></q></dir></style></legend>