• <legend id='cpqft'><style id='cpqft'><dir id='cpqft'><q id='cpqft'></q></dir></style></legend>

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

      • <bdo id='cpqft'></bdo><ul id='cpqft'></ul>
      <tfoot id='cpqft'></tfoot>

      <i id='cpqft'><tr id='cpqft'><dt id='cpqft'><q id='cpqft'><span id='cpqft'><b id='cpqft'><form id='cpqft'><ins id='cpqft'></ins><ul id='cpqft'></ul><sub id='cpqft'></sub></form><legend id='cpqft'></legend><bdo id='cpqft'><pre id='cpqft'><center id='cpqft'></center></pre></bdo></b><th id='cpqft'></th></span></q></dt></tr></i><div id='cpqft'><tfoot id='cpqft'></tfoot><dl id='cpqft'><fieldset id='cpqft'></fieldset></dl></div>
      1. 通过 PHP 表单进行 FTP 上传

        时间:2023-10-30
        <legend id='MrhLY'><style id='MrhLY'><dir id='MrhLY'><q id='MrhLY'></q></dir></style></legend>

            <tbody id='MrhLY'></tbody>

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

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

                  <tfoot id='MrhLY'></tfoot>
                  本文介绍了通过 PHP 表单进行 FTP 上传的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我想通过 FTP 上传表单中的文件.

                  I want to upload a file via FTP upload in a form.

                  <html>
                    <body>
                      <form enctype="multipart/form-data" action="upload_file.php" method="POST">
                        <input type="hidden" name="MAX_FILE_SIZE" value="100000" />
                        Choose a file to upload: <input name="uploadedfile" type="file" /><br />
                        <input type="submit" value="Upload File" />
                      </form>
                    </body>
                  </html>
                  

                  这里是 PHP 文件:

                  Here is the PHP file:

                  <?php
                  
                  $ftp_server = "xxx";
                  $ftp_username   = "xxx";
                  $ftp_password   =  "xxx";
                  
                  // setup of connection
                  $conn_id = ftp_connect($ftp_server) or die("could not connect to $ftp_server");
                  
                  // login
                  if (@ftp_login($conn_id, $ftp_username, $ftp_password))
                  {
                    echo "conectd as $ftp_username@$ftp_server
                  ";
                  }
                  else
                  {
                    echo "could not connect as $ftp_username
                  ";
                  }
                  
                  $file = $_FILES["file"]["name"];
                  $remote_file_path = "/home/www/lifestyle69/import/".$file;
                  ftp_put($conn_id, $remote_file_path, $file, FTP_ASCII);
                  ftp_close($conn_id);
                  echo "
                  
                  connection closed";
                  
                  ?>
                  

                  FTP连接成功,但文件不存在.

                  The FTP connection connects successfully but the file is nowhere.

                  谁能帮帮我?

                  谢谢!

                  推荐答案

                  因为你有 <input name="uploadedfile" type="file"/>:

                  $file = $_FILES["file"]["name"]; // wrong
                  $file = $_FILES["uploadedfile"]["name"]; // right
                  

                  因为你需要PHP存储的临时副本的文件名,它存在于服务器上:

                  Because you need the filename of the temporary copy stored by PHP, which exists on the server:

                  ftp_put($conn_id, $remote_file_path, $file, FTP_ASCII); // wrong
                  ftp_put($conn_id, $remote_file_path, $_FILES["uploadedfile"]["tmp_name"],
                          FTP_ASCII); // right
                  

                  有关详细信息,请参阅 PHP 文档大约 $_FILES.

                  Refer to the PHP documentation for more information about $_FILES.

                  这篇关于通过 PHP 表单进行 FTP 上传的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:PHP FTP ftp_nlist 不起作用,返回布尔值 false 下一篇:使用 PHP 访问 FTP 目录列表

                  相关文章

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

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