我正在处理PHP文件上传。首先,我只用HTML/PHP代码尝试没有任何上传(uploadify)等使用PHP上传大文件
的HTML代码
<form method="post" action="" enctype="multipart/form-data">
<label for="upload">Select : </label>
<input type="file" name="file_upload" id="upload" multiple="multiple" />
<!-- 1024 x 1024 x 1024 -->
<input type="hidden" name="MAX_FILE_SIZE" value="1073741824" />
<input type="submit" name="fsubmit" id="fsubmit" value="Upload" />
</form>
PHP代码
if (isset($_FILES['file_upload']) && $_FILES['file_upload']['error'] == 0) {
move_uploaded_file($_FILES[$field_name]['tmp_name'], '../somepath/.../' . $_FILES['file_upload']['name');
} else {
echo $_FILES['file_upload']['error'];
}
它上传文件小于8Mb的。要覆盖PHP默认值,我将.htaccess
更改为此并重新启动apache。
php_value upload_max_filesize 1024M # also tried "1024M"
php_value post_max_size 1024M # also tried "1024M"
php_value max_execution_time 3600
php_value max_input_time 3600
,但没有运气,它始终以默认8M
。我也试图改变从PHP代码的设置上飞这样
ini_set('upload_max_filesize', '1024M');
ini_set('post_max_size', '1024M');
ini_set('max_execution_time', '600');
ini_set('max_input_time', '600');
ini_set('memory_limit', -1); // no memory limit
这也没有任何效果,当我echo ini_get('post_max_size')
它显示8M
。错误代码返回的是2显示PHP说
UPLOAD_ERR_FORM_SIZE
Value: 2; The uploaded file exceeds the MAX_FILE_SIZE directive that was specified in the HTML form.
现在的问题是,为什么它不能从.htacess
或PHP代码重写? 注意我在VPS服务器上。当我手动更改8M到xM
时,它可以工作。希望我很清楚,在此先感谢...
这些变量的值是什么ini_get(),我想它没有被覆盖 – zamil 2013-02-18 05:15:41
@zamil,我已经说过它没有被覆盖,但为什么? – 2013-02-18 05:22:25
请联系您的托管公司,询问他们是否对这些变量的最大值应用了任何上限。例如:http://support.hostgator.com/articles/cpanel/php-settings-that-cannot-be-changed – zamil 2013-02-18 05:23:27