使用php页面崩溃将大文件上传到ftp服务器时

时间:2013-05-09 10:22:58

标签: php html5 file-upload ftp

我有以下问题,我使用HTML5 filedrop上传33.3MB文件。首先,我将文件保存到本地存储,然后将其传输到ftp服务器。大约1分钟后页面崩溃,(文件保存到本地存储后)。我注意到它继续上传,每次刷新页面时我都看到文件大小增加。最后它是在后台上传的,但我当然不希望页面崩溃。如果有人知道原因请回复我。我增加了upload_max_filesize,post_max_size并且我也增加了超时。

$userName = "username";
$pass = "pass";
$root = "FolderBBB";


ini_set('default_socket_timeout', '1000');
ini_set('upload_max_filesize',  '1024M');
ini_set('post_max_size', '1024M');
ini_set('max_execution_time', '1000');
ini_set('max_input_time', '1000');
ini_set('memory_limit', '1024M'); 

$conn = ftp_connect("path",2121,1800) or die("Could not connect");
if (ftp_login($conn, $userName, $pass)){
    @ftp_pasv($conn,TRUE);
      set_time_limit(0);
        if ($_FILES && $_FILES["file"] && $_FILES["file"]["tmp_name"]){
            $fullPath = $root.$_POST["path"]."/".$_FILES["file"]["name"];
            if (ftp_exists($conn, $fullPath)){
                echo "{\"check\": false,\"text\":\"File already exists on server.\"}";
            }else{
                if(move_uploaded_file($_FILES["file"]["tmp_name"],  $_FILES["file"]["name"])){
                    // echo $root.$_POST["path"]."/".$_FILES["file"]["name"];
                    if(ftp_put($conn, $fullPath, $_FILES["file"]["name"], FTP_BINARY)){
                        unlink($_FILES["file"]["name"]);
                        echo "{\"check\":true, \"text\":\"File(s) were uploaded successfully.\"}";
                    }else{
                        echo "{\"check\": false, \"text\":\"File ".$_FILES["file"]["name"]." was not uploaded successfully.\"}";
                    }
                }else{
                    echo "{\"check\": false, \"text\":\"File ".$_FILES["file"]["name"]." was not uploaded successfully.\"}";
                }
            }
        }
}

0 个答案:

没有答案