用PHP上传大文件 [英] Upload large files in PHP

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

问题描述

我创建了简单的html表单来上传服务器中的文件。之后我将我的页面上传到共享服务器。但他们已将 max_file_uploads post_max_size 设置为16MB,并且由于安全性,他们不允许更改它。我想上传最少500MB到1GB的文件。

我试过

 ini_set('  upload_max_filesize''  1024M'); 
ini_set(' post_max_size'' 1024M');



但它不起作用。

我尝试过.htaccess但它也不起作用。

我已经探索了一些Flash和Java Applet。但是我不能用它。

我已经阅读了一些文章来分割大块文件,但我找不到任何有用的解决方案。

请有人帮帮我上传大文件而不更改php.ini文件。

解决方案

upload_max_filesize和post_max_size是PHP_INI_PERDIR模式的php.ini指令,只能在php.ini,.htaccess中设置,httpd.conf。

尝试使用以下条目在您的web文件夹中创建一个.htaccess:

 php_value upload_max_filesize 1024M 
php_value post_max_size 1024M



然后,启动一个带有以下代码的php页面来检查更改的设置:

 echo ini_get('的upload_max_filesize'); 


I have created simple html form to upload file in server. After that I have uploaded my page at shared Server. But they have set max_file_uploads and post_max_size to 16MB and they don't allow to change it due to security. I want to upload minimum 500MB to 1GB files.
I tried

ini_set('upload_max_filesize', '1024M');
    ini_set('post_max_size', '1024M');


But it don't work.
After I have tried .htaccess but it also doesn't work.
I have explored some Flash and Java Applet. but I can't use it.
I have read some articles to split large files in chunk but I can't find any working solutions.
Please someone help me to upload large files without changing php.ini file.

解决方案

upload_max_filesize and post_max_size are php.ini directives of PHP_INI_PERDIR mode which can only be set in php.ini, .htaccess, httpd.conf.
Try create a .htaccess in your web folder with the following entries:

php_value upload_max_filesize 1024M
php_value post_max_size 1024M


then, launch a php page with the following code to check the changed settings:

echo ini_get('upload_max_filesize');


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

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