上传使用PHP大文件,阿帕奇 [英] upload large files using php, apache

查看:173
本文介绍了上传使用PHP大文件,阿帕奇的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要上传的使用PHP和Apache服务器大约150 MB的文件。
用我的code I可以上传高达5MB

 < PHP$ PATH = $ _COOKIE ['mypath中'];
$ target_path =上传/\".$路径;
如果(!ISDIR($ target_path))
{
    的mkdir($ target_path);
}
    #在这里做上传
   $ target_path =上传/\".$路径/;
   $ target_path = $ target_path。基本名($ _FILES ['UploadedFile的'] ['名']);
   如果(move_uploaded_file($ _ FILES ['UploadedFile的'] ['tmp_name的值'],$ target_path))
   {
      标题(位置:somepage.html);
   }
   其他
   {
        回声文件没有上传;
   }?>

的php.ini

 的max_execution_time = 300;每个脚本的最大执行时间,以秒为单位
max_input_time设置= 300;最长时间每个脚本可能会花费解析请求数据
; max_input_nesting_level = 64;最大输入变量嵌套层次
memory_limit的= 128M;的最大内存量的脚本可能消耗(128MB)
file_uploads =开;对于HTTP上传的文件的临时目录(将使用系统默认如果不
;指定)。
; upload_tmp_dir =;允许的最大尺寸上传的文件。
的upload_max_filesize = 200M


解决方案

我还检查最大输入时间和脚本的执行时间。他们目前都设置为300秒(5分钟)。这将意味着用户必须在300秒内上传150 MB(1200兆比特)。这意味着,最终用户需要的固体和一致4Mbps的连接(1200/300 = 4),上载文件中所分配的时间。

我会推荐类似这些设置的内容:

  file_uploads =开
upload_tmp_dir =/你的/ tmp /目录
的upload_max_filesize = 150M;您可能要碰到这1.51亿,如果你有150 MB的文件的问题
的max_execution_time = 1200; 20分钟后,这是在1Mbps的一个150 Mb文件
max_input_time设置= 1200

I want to upload files of around 150 MB using PHP and Apache server. With my code i can upload upto 5MB

<?php

$path = $_COOKIE['Mypath'];
$target_path = "uploads/".$path ;
if(!isDir($target_path))
{
    mkdir($target_path);
}
    # Do uploading here
   $target_path = "uploads/".$path ."/";
   $target_path = $target_path . basename( $_FILES['uploadedfile']['name']); 
   if(move_uploaded_file($_FILES['uploadedfile']['tmp_name'], $target_path))
   {
      header("Location: somepage.html");
   } 
   else
   {
        echo "File not uploaded";
   }

?>

php.ini

max_execution_time = 300     ; Maximum execution time of each script, in seconds
max_input_time = 300    ; Maximum amount of time each script may spend parsing request data
;max_input_nesting_level = 64 ; Maximum input variable nesting level
memory_limit = 128M      ; Maximum amount of memory a script may consume (128MB)
file_uploads = On

; Temporary directory for HTTP uploaded files (will use system default if not
; specified).
;upload_tmp_dir =

; Maximum allowed size for uploaded files.
upload_max_filesize = 200M

解决方案

I'd also check the max input time and script execution time. They're both currently set to 300 seconds (5 minutes). That would mean the user has to upload 150 mb (1200 mega-bits) in 300 seconds. That means the end user would need a solid and consistent 4mbps connection (1200 / 300 = 4) to upload that file in the allotted time.

I would recommend something similar to these settings:

file_uploads = On
upload_tmp_dir = "/your/tmp/dir"
upload_max_filesize = 150M ; You may want to bump this to 151M if you have problems with 150 mb files
max_execution_time = 1200 ; 20 minutes, which is a 150 mb file at 1mbps
max_input_time = 1200

这篇关于上传使用PHP大文件,阿帕奇的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆