1GB文件上传使用PHP [英] 1GB file upload using php

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

问题描述

我试图用php脚本上传一个1GB大小的文件,如果文件大小小于20MB,可以工作得很好,但是当我增加文件大小的时候比在网站上按上传按钮的时候上传的文件(我想因为它需要几分钟),然后,而不是执行upload.php,我的Firefox要求我下载upload.php,所以我猜,文件正在上传,但我的PHP脚本无法执行。

同样在google搜索后,我发现了php.ini的设置,我的php_info()函数显示设置已经被更改了。



/ * php.ini start * /



memory_limit = 512M



post_max_size = 15000M
$ b $ file_uploads =在
$ b $ p上传max_filesize = 15000M p>

max_input_time = 20000

max_execution_time = 20000

会话.gc_maxlifetime = 20000



/ * php.ini结束 * /

解决方案

限制文件大小的上传受LOT的限制,不仅仅是PHP。 PHP有其局限性,Apache有其局限性,许多Web服务都有自己的限制,然后对共享主机上的用户权限可以设置的/ tmp目录大小有限制。更不用说硬盘空间不足了!



您的php.ini看起来不错,但是正如已经建议的那样,检查Apache中的LimitRequestBody并确保您的web服务当你需要上传非常大的文件时,一个常见的解决方案是在客户端使用Flash或Java,因为它们可以访问客户端的实际文件系统。然后,Flash / Java可以将文件分解成小块,一次发送一个小块,然后在服务器端重新组装。这有多个好处。首先,您可以恢复中断的下载。其次,你不必担心任何脚本超时。第三,它绕过了PHP,Apache,Web服务或其他来源可能发挥的任何可能的文件系统限制。


I am trying to upload a file of 1GB size using php script and it works perfectly if file size is less than 20MB, but when I increase the file size than after pressing upload button on website, it uploads the file (I guess as it takes few minutes) and after that, instead to execute upload.php, my firefox asks me to download upload.php, so I guess, file is being uploaded but my php script fails to execute.

Also after searching in google I found following settings for php.ini which I made and my php_info() function shows me that settings have been changed..

/*php.ini start*/

memory_limit = 512M

post_max_size = 15000M

file_uploads = On

upload_max_filesize = 15000M

max_input_time = 20000

max_execution_time = 20000

session.gc_maxlifetime = 20000

/*php.ini end*/

解决方案

The limit on file size uploads is limited by a LOT more than just PHP. PHP has its limits, Apache has its limits, many web services have their own limits, and then you have the limit on the /tmp directory size which could be set by user permissions on a shared host. Not to mention just running out of hard drive space!

Your php.ini looks good, but as was already suggested- check the LimitRequestBody in Apache and make sure your web service allows this.

One common solution when you need to upload very large files is to use Flash or Java on the client-side since these have access to the client's actual file system. The Flash/Java can then break the file into small pieces which are sent one at a time and re-assembled on the server side. This has multiple benefits. First, you can resume broken downloads. Second, you don't have to worry about any scripts timing out. Third, it bypasses any possible file system limits that may be in play from PHP, Apache, web services, or other sources.

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

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