• <tfoot id='RyWr1'></tfoot>

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

    • <bdo id='RyWr1'></bdo><ul id='RyWr1'></ul>

        <small id='RyWr1'></small><noframes id='RyWr1'>

        <legend id='RyWr1'><style id='RyWr1'><dir id='RyWr1'><q id='RyWr1'></q></dir></style></legend>

        如何使用 HTTP POST 使用 HTML 和 PHP 选择和上传多个文件?

        时间:2023-12-02
        <legend id='kBLFP'><style id='kBLFP'><dir id='kBLFP'><q id='kBLFP'></q></dir></style></legend>
            <tbody id='kBLFP'></tbody>
            <bdo id='kBLFP'></bdo><ul id='kBLFP'></ul>

              <small id='kBLFP'></small><noframes id='kBLFP'>

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

              • <tfoot id='kBLFP'></tfoot>
                  本文介绍了如何使用 HTTP POST 使用 HTML 和 PHP 选择和上传多个文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我有使用 <input type="file"> 上传单个文件的经验.但是,我无法一次上传多个文件.

                  例如,我想选择一系列图像,然后一次性将它们上传到服务器.

                  如果可能,最好使用单个文件输入控件.

                  有谁知道如何做到这一点?

                  解决方案

                  这在 PHP 中的文件上传.

                  I have experience doing this with single file uploads using <input type="file">. However, I am having trouble doing uploading more than one at a time.

                  For example, I'd like to select a series of images and then upload them to the server, all at once.

                  It would be great to use a single file input control, if possible.

                  Does anyone know how to accomplish this?

                  解决方案

                  This is possible in HTML5. Example (PHP 5.4):

                  <!doctype html>
                  <html>
                      <head>
                          <title>Test</title>
                      </head>
                      <body>
                          <form method="post" enctype="multipart/form-data">
                              <input type="file" name="my_file[]" multiple>
                              <input type="submit" value="Upload">
                          </form>
                          <?php
                              if (isset($_FILES['my_file'])) {
                                  $myFile = $_FILES['my_file'];
                                  $fileCount = count($myFile["name"]);
                  
                                  for ($i = 0; $i < $fileCount; $i++) {
                                      ?>
                                          <p>File #<?= $i+1 ?>:</p>
                                          <p>
                                              Name: <?= $myFile["name"][$i] ?><br>
                                              Temporary file: <?= $myFile["tmp_name"][$i] ?><br>
                                              Type: <?= $myFile["type"][$i] ?><br>
                                              Size: <?= $myFile["size"][$i] ?><br>
                                              Error: <?= $myFile["error"][$i] ?><br>
                                          </p>
                                      <?php
                                  }
                              }
                          ?>
                      </body>
                  </html>
                  

                  Here's what it looks like in Chrome after selecting 2 items in the file dialog:

                  And here's what it looks like after clicking the "Upload" button.

                  This is just a sketch of a fully working answer. See PHP Manual: Handling file uploads for more information on proper, secure handling of file uploads in PHP.

                  这篇关于如何使用 HTTP POST 使用 HTML 和 PHP 选择和上传多个文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:上传的安全威胁 下一篇:在 PHP 上更改 upload_max_filesize

                  相关文章

                    • <bdo id='nBZjg'></bdo><ul id='nBZjg'></ul>
                  1. <tfoot id='nBZjg'></tfoot>

                    1. <small id='nBZjg'></small><noframes id='nBZjg'>

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

                      <legend id='nBZjg'><style id='nBZjg'><dir id='nBZjg'><q id='nBZjg'></q></dir></style></legend>