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

  2. <small id='sifAL'></small><noframes id='sifAL'>

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

      使用 PHP 将大文件上传到 FTP

      时间:2023-10-30
    1. <small id='bc0RU'></small><noframes id='bc0RU'>

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

        1. <tfoot id='bc0RU'></tfoot>
          • <bdo id='bc0RU'></bdo><ul id='bc0RU'></ul>
            • <legend id='bc0RU'><style id='bc0RU'><dir id='bc0RU'><q id='bc0RU'></q></dir></style></legend>

                  <tbody id='bc0RU'></tbody>

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

                问题描述

                我正在尝试使用 php 将大文件上传到 ftp 服务器.我可以上传小文件,但上传大文件时遇到问题.我查了一下,发现需要设置upload_max_filesize和post_max_size,设置ftp为被动模式,设置时间限制为never.我没有设置时间限制,我现在没有返回任何错误,但它也没有上传文件.如果您查看底部的 if (!$upload) { 行,它应该会回显某些内容,但事实并非如此.更重要的是,它只是不起作用.关于出了什么问题或我需要做些什么来完成这项工作的任何见解?谢谢!

                I'm trying to upload large files with php to an ftp server. I can upload small files, but I'm having trouble uploading larger files. I have looked it up and found that I need to set upload_max_filesize and post_max_size, set ftp to passive mode, and set time limit to never. I had no luck with setting the time limit, and what I have now isn't returning any errors, but it is also not uploading the file. If you look at the if (!$upload) { line at the bottom, it should echo something, but it isn't. More importantly, it just isn't working. Any insight as to what is going wrong or what I need to do to make this work? Thank you!

                ini_set('upload_max_filesize', '50M');   
                ini_set('post_max_size', '50M');  
                
                $conn_id = ftp_connect($ftp_server);
                
                // 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;
                }
                
                 // turn passive mode on
                ftp_pasv($conn_id, true);
                
                if($_FILES['upload_file']['name']!=''){
                    $source_file = $_FILES['upload_file']['tmp_name'];
                    $destination_file = $_FILES['upload_file']['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!<br />";
                        } else {
                            echo "Uploaded $source_file to $ftp_server as $destination_file<br />";
                        }       
                }
                

                更新

                我发现我无法从 php 页面设置 upload_max_filesize 值;另外,我似乎无法让 .htaccess 工作:如果我有一个 .htaccess 文件,则会导致 HTTP 错误 500.此外,我无权访问 php.ini.

                UPDATE

                I've discovered that I cannot set the upload_max_filesize value from the php page; also, I can't seem to get .htaccess to work: if I have an .htaccess file it results in a HTTP Error 500. Also, I don't have access to php.ini.

                我还能如何更改upload_max_filesize 值?

                How else can I change the upload_max_filesize value?

                我的网络管理员告诉我,我使用的是基于 IIS Windows 的系统,因此 .htaccess 文件将无法工作.有没有办法可以通过 web.config 影响文件上传大小?

                My web administrator has told me that I am on an IIS windows-based system, so .htaccess files won't work. Is there a way that I can affect the file upload size with web.config?

                推荐答案

                来自这个网站:http://www.php.net/manual/en/ini.php

                'upload_max_filesize' 和 'post_max_size'

                'upload_max_filesize' and 'post_max_size'

                属于 PHP_INI_PERDIR 类型

                are of type PHP_INI_PERDIR

                表示Entry可以在php.ini, .htaccess or httpd.conf"中设置.所以你不能在你的脚本中设置它.

                which means Entry can be set in "php.ini, .htaccess or httpd.conf". So you can't set it in your script.

                --- 编辑---

                一个类似的问题:在 PHP 上更改 upload_max_filesize

                --- 编辑 2 ---

                --- Edit 2 ---

                就个人而言,我想做同样的事情(通过 ftp 上传大文件)并最终编写一个 java 应用程序.对于处理大文件,php 并不是最好的方法.Web 浏览器并不喜欢这样.因此,对于处理大文件,我建议查看其他替代方案:(java, swf, javascript, ...)

                Personally, I wanted to do the same kind of stuff (upload large files over ftp) and end up writing a java application. For handling large files, php is not really the best way. Web browsers doesn't really like that. So, for handling large files, I would suggest to look at other alternative: (java, swf, javascript, ...)

                我有空想试试 http://nodejs.org/

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

                上一篇:OpenSSL 已启用但无法正常工作 下一篇:单独的文件 &amp;PHP中的目录

                相关文章

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

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

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