上载大文件并暂停php上载

上载大文件并暂停php上载,php,Php,客户端的站点上载文件,但如果这些文件很大,则返回超时错误503服务不可用 hopedagem将超时时间限制在300秒以内,有没有办法通过js或相关文件上传而不超时? 上传是视频 托管服务器不允许超时编辑。转到php.ini文件并根据您的要求更改值 上传最大文件大小 默认情况下,此值为2M。我们需要将它增加到我们想要上传的单个文件的最大大小 最大输入时间 这将设置允许脚本解析输入数据的最长时间(秒),如POST和GET。计时从服务器上调用PHP的那一刻开始,到执行开始时结束。这将包括填充超全局的$

客户端的站点上载文件,但如果这些文件很大,则返回超时错误
503服务不可用

hopedagem将超时时间限制在300秒以内,有没有办法通过js或相关文件上传而不超时? 上传是视频


托管服务器不允许超时编辑。

转到
php.ini
文件并根据您的要求更改值

上传最大文件大小

默认情况下,此值为2M。我们需要将它增加到我们想要上传的单个文件的最大大小

最大输入时间

这将设置允许脚本解析输入数据的最长时间(秒),如
POST
GET
。计时从服务器上调用PHP的那一刻开始,到执行开始时结束。这将包括填充超全局的
$\u文件

内存限制

这将设置PHP脚本在执行期间允许使用的内存量。将该值设置为大于“
post_max_size
”的值,以便PHP脚本可以加载和处理上载的文件

贴子最大尺寸

它定义了PHP将接受的POST数据的最大大小。此值应大于“
upload\u max\u filesize

最大执行时间

脚本输入被解析后允许运行的时间。这将包括对文件本身的任何处理

如果出现与内存相关的错误,请关闭输出缓冲,需要考虑的PHP配置指令是“
output\u buffering

output_buffering = Off

此外,我还添加了上述配置的参考,您可以找到更多详细信息

您需要在php.ini中更改一些设置:

upload_max_filesize = 500M 
;or whatever size you want

max_execution_time = 1000
; also, higher if you must - sets the maximum time in seconds
决议如下:


您的浏览器不支持Flash、Silverlight或HTML5

$(函数(){ $(“#上传器”).plupload({ //一般设置 运行时:“html5、flash、silverlight、html4”, url:“controller/xml_upload.php”, //最大文件大小 最大文件大小:“2048mb”, 块大小:“1mb”, //指定要浏览的文件 过滤器:[ {标题:“XML”,扩展:“XML”} ], //通过单击文件标题重命名文件 重命名:对, //排序文件 可排序:是的, //允许将文件拖放到小部件上(目前只有HTML5支持此功能) dragdrop:false, //要激活的视图 观点:{ 列表:false, 拇指:false,//显示拇指 活动:“拇指” }, //闪光设置 flash_swf_url:'/videos_add1_up/Moxie.swf', //Silverlight设置 silverlight\u xap\u url:'/videos\u add1\u up/Moxie.xap', 多部分参数:{ “xml\u usuario”:“xml\u用户” } }); });
PHP

标题(“到期日期:1997年7月26日星期一05:00:00 GMT”);
标题(“上次修改:”.gmdate(“D,D M Y H:i:s”)“GMT”);
标头(“缓存控制:无存储,无缓存,必须重新验证”);
标头(“缓存控制:后检查=0,预检查=0”,false);
标题(“杂注:无缓存”);
@设置时间限制(5*60);
$targetDir='../../assets/arquivos/xml/';
$cleanupTargetDir=true;
$maxFileAge=5*3600;
如果(!file_存在($targetDir)){
@mkdir($targetDir);
}
如果(isset($_请求[“名称])){
$fileName=$_请求[“name”];
}elseif(!空($\u文件)){
$fileName=$_文件[“文件”][“名称”];
}否则{
$fileName=uniqid(“文件”);
}
包括“../../\u config.php”;
$filePath=$targetDir。目录分隔符$文件名;
//可能会启用分块
$chunk=isset($\u请求[“chunk”])?intval($_请求[“块]):0;
$chunks=isset($\u请求[“chunks”])?intval($_请求[“块]):0;
如果($cleanupTargetDir){
如果(!is_dir($targetDir)| |!$dir=opendir($targetDir)){
die(“{”jsonrpc:“2.0”,“错误:{”代码:100,“消息”:“未能打开临时目录。”},“id”:“id”}”);
}
while(($file=readdir($dir))!==false){
$tmpfilePath=$targetDir.DIRECTORY\u SEPARATOR.$file;
//如果临时文件是当前文件,请转至下一个文件
if($tmpfilePath==“{$filePath}.part”){
继续;
}
//如果临时文件早于最大期限且不是当前文件,请删除该文件
if(preg_match('/\.part$/',$file)&&(filemtime($tmpfilePath)    <div id="uploader">
        <p>Your browser doesnt have Flash, Silverlight or HTML5 support.</p>
    </div>


    <link href="https://rawgithub.com/moxiecode/plupload/master/js/jquery.plupload.queue/css/jquery.plupload.queue.css" type="text/css" rel="stylesheet" media="screen">
    <script type="text/javascript" src="assets/uploads/jquery-ui.js"></script>
    <script type="text/javascript" src="assets/uploads/plupload.full.min.js"></script>
    <script type="text/javascript" src="assets/uploads/jquery.plupload.queue/jquery.plupload.queue.min.js"></script>
    <script type="text/javascript" src="assets/uploads/jquery.ui.plupload/jquery.ui.plupload.min.js"></script>
    <link type="text/css" rel="stylesheet" href="assets/uploads/jquery.ui.plupload/css/jquery.ui.plupload.css" media="screen" />

    <script type="text/javascript" src="assets/uploads/i18n/pt_BR.js"></script>


    <script type="text/javascript">
    $(function() {
        $("#uploader").plupload({
            // General settings
            runtimes : 'html5,flash,silverlight,html4',
            url : "controller/xml_upload.php",

            // Maximum file size
            max_file_size : '2048mb',

            chunk_size: '1mb',

            // Specify what files to browse for
            filters : [
                {title : "XML", extensions : "xml"}
            ],

            // Rename files by clicking on their titles
            rename: true,

            // Sort files
            sortable: true,

            // Enable ability to drag'n'drop files onto the widget (currently only HTML5 supports that)
            dragdrop: false,

            // Views to activate
            views: {
                list: false,
                thumbs: false, // Show thumbs
                active: 'thumbs'
            },

            // Flash settings
            flash_swf_url : '/videos_add1_up/Moxie.swf',

            // Silverlight settings
            silverlight_xap_url : '/videos_add1_up/Moxie.xap',

            multipart_params : {
                "xml_usuario" : "xml_user"
            }
        });
    });
    </script>
    header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
    header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
    header("Cache-Control: no-store, no-cache, must-revalidate");
    header("Cache-Control: post-check=0, pre-check=0", false);
    header("Pragma: no-cache");
    @set_time_limit(5 * 60);
    $targetDir = '../../assets/arquivos/xml/';
    $cleanupTargetDir = true; 
    $maxFileAge = 5 * 3600; 

    if (!file_exists($targetDir)) {
        @mkdir($targetDir);
    }

    if (isset($_REQUEST["name"])) {
        $fileName = $_REQUEST["name"];
    } elseif (!empty($_FILES)) {
        $fileName = $_FILES["file"]["name"];
    } else {
        $fileName = uniqid("file_");
    }




    include '../../_config.php';

    $filePath = $targetDir . DIRECTORY_SEPARATOR . $fileName;

    // Chunking might be enabled
    $chunk = isset($_REQUEST["chunk"]) ? intval($_REQUEST["chunk"]) : 0;
    $chunks = isset($_REQUEST["chunks"]) ? intval($_REQUEST["chunks"]) : 0;


    if ($cleanupTargetDir) {
        if (!is_dir($targetDir) || !$dir = opendir($targetDir)) {
            die('{"jsonrpc" : "2.0", "error" : {"code": 100, "message": "Failed to open temp directory."}, "id" : "id"}');
        }

        while (($file = readdir($dir)) !== false) {
            $tmpfilePath = $targetDir . DIRECTORY_SEPARATOR . $file;

            // If temp file is current file proceed to the next
            if ($tmpfilePath == "{$filePath}.part") {
                continue;
            }

            // Remove temp file if it is older than the max age and is not the current file
            if (preg_match('/\.part$/', $file) && (filemtime($tmpfilePath) < time() - $maxFileAge)) {
                @unlink($tmpfilePath);
            }
        }
        closedir($dir);
    }   


    if (!$out = @fopen("{$filePath}.part", $chunks ? "ab" : "wb")) {
        die('{"jsonrpc" : "2.0", "error" : {"code": 102, "message": "Failed to open output stream."}, "id" : "id"}');
    }

    if (!empty($_FILES)) {
        if ($_FILES["file"]["error"] || !is_uploaded_file($_FILES["file"]["tmp_name"])) {
            die('{"jsonrpc" : "2.0", "error" : {"code": 103, "message": "Failed to move uploaded file."}, "id" : "id"}');
        }

        // Read binary input stream and append it to temp file
        if (!$in = @fopen($_FILES["file"]["tmp_name"], "rb")) {
            die('{"jsonrpc" : "2.0", "error" : {"code": 101, "message": "Failed to open input stream."}, "id" : "id"}');
        }
    } else {    
        if (!$in = @fopen("php://input", "rb")) {
            die('{"jsonrpc" : "2.0", "error" : {"code": 101, "message": "Failed to open input stream."}, "id" : "id"}');
        }
    }

    while ($buff = fread($in, 4096)) {
        fwrite($out, $buff);
    }

    @fclose($out);
    @fclose($in);

    // Check if file has been uploaded
    if (!$chunks || $chunk == $chunks - 1) {
        // Strip the temp .part suffix off 
        rename("{$filePath}.part", $filePath);
    }