douchuifk90315 2013-05-09 10:22
浏览 28

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

I have the following problem, I am uploading 33.3MB file using HTML5 filedrop. First I save the file to local storage and then I transfer it to ftp server. the page crashes after about 1 minute,(after the file is saved to local storage). I noticed that it continues uploading, every time I refresh the page I see that the file size increases. Finally it is uploaded in background but my of course I do not want the page to be crashed. If someone knows the reason please reply me. I have increased upload_max_filesize, post_max_size and I increased timeout too.

$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条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥60 求一个简单的网页(标签-安全|关键词-上传)
    • ¥35 lstm时间序列共享单车预测,loss值优化,参数优化算法
    • ¥15 基于卷积神经网络的声纹识别
    • ¥15 Python中的request,如何使用ssr节点,通过代理requests网页。本人在泰国,需要用大陆ip才能玩网页游戏,合法合规。
    • ¥100 为什么这个恒流源电路不能恒流?
    • ¥15 有偿求跨组件数据流路径图
    • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值
    • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
    • ¥15 一直显示正在等待HID—ISP
    • ¥15 Python turtle 画图