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

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

      <bdo id='xcgdM'></bdo><ul id='xcgdM'></ul>

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

        使用 PHP 将单个图像文件上传到 FTP

        Upload single image file to FTP using PHP(使用 PHP 将单个图像文件上传到 FTP)
          <tbody id='aXsKT'></tbody>

        <legend id='aXsKT'><style id='aXsKT'><dir id='aXsKT'><q id='aXsKT'></q></dir></style></legend><tfoot id='aXsKT'></tfoot>

            <bdo id='aXsKT'></bdo><ul id='aXsKT'></ul>

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

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

                • 本文介绍了使用 PHP 将单个图像文件上传到 FTP的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  把我的头发拉出来一点.我想做的只是有一个 HTML 表单,然后 PHP 将所选文件上传到 FTP 服务器上的某个目录,但似乎没有任何工作正常.

                  Pulling my hair out a bit here. All I want to do is have a HTML form and then PHP to upload the selected file to a certain directory on an FTP server, but nothing seems to be working correctly.

                  这是 html 表单:

                  Here's the html form :

                  <form action="" enctype="multipart/form-data" method="post">
                  <input name="file" type="file" />
                  <input name="submit" type="submit" value="Upload File" />
                  </form>
                  

                  这是它下面的 PHP(在同一个文件上):

                  And here's the PHP below it (on the same file):

                  <?php
                  $ftp_server = "myftp.co.uk";
                  $ftp_user_name = "myusername";
                  $ftp_user_pass = "mypass";
                  $destination_file = "/public_html/my/directory/";
                  $source_file = $_POST['file']['tmp_name'];
                  
                  // set up basic connection
                  $conn_id = ftp_connect($ftp_server);
                  ftp_pasv($conn_id, true); 
                  
                  // login with username and password
                  $login_result = ftp_login($conn_id, $ftp_user_name, $ftp_user_pass); 
                  
                  // check connection
                  if ((!$conn_id) || (!$login_result)) { 
                      echo "FTP connection has failed!";
                      echo "Attempted to connect to $ftp_server for user $ftp_user_name"; 
                      exit; 
                  } else {
                      echo "Connected to $ftp_server, for user $ftp_user_name";
                  }
                  
                  // upload the file
                  $upload = ftp_put($conn_id, $destination_file, $source_file, FTP_BINARY); 
                  
                  // check upload status
                  if (!$upload) { 
                  echo "FTP upload has failed!";
                  } else {
                  echo "Uploaded $source_file to $ftp_server as $destination_file";
                  }
                  
                  // close the FTP stream 
                  ftp_close($conn_id);
                  ?>
                  

                  似乎连接到 FTP 正常,但没有上传 - 失败.我假设这与我处理要上传的文件的方式有关..?

                  It seems to connect to the FTP ok, but doesn't upload - failed. I'm assuming it's something to do with the way I'm handling the file to be uploaded..?

                  另外,当我在这里时,如何将已上传文件的名称设置为变量?

                  Also, while I'm here, how do I set the name of the file that's been uploaded as a variable?

                  推荐答案

                  在这里修改你的代码

                  $source_file = $_FILES['file']['tmp_name']; 
                  

                  这里我把 $_POST 改成了 $_FILES....

                  Here i have changed $_POST to $_FILES....

                  这篇关于使用 PHP 将单个图像文件上传到 FTP的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

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

                  相关文档推荐

                  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 的问题)
                      <tbody id='7hrif'></tbody>
                  1. <small id='7hrif'></small><noframes id='7hrif'>

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

                        <legend id='7hrif'><style id='7hrif'><dir id='7hrif'><q id='7hrif'></q></dir></style></legend><tfoot id='7hrif'></tfoot>
                            <bdo id='7hrif'></bdo><ul id='7hrif'></ul>