用php上传大文件
我上传的文件在昨晚完成工作之前一直在工作,但今天当我试图上传一个大于2MB的文件时,我遇到了一个异常用php上传大文件,php,file-upload,Php,File Upload,我上传的文件在昨晚完成工作之前一直在工作,但今天当我试图上传一个大于2MB的文件时,我遇到了一个异常“文件太大(服务器异常)。”有人能告诉我为什么会出现这个问题,因为2MB不是php无法处理的大文件。我的上传脚本是: function uploadFile(){ if ( $this->error == 0 ){ if ( $this->destination == null ){ if ( $this-&
“文件太大(服务器异常)。”
有人能告诉我为什么会出现这个问题,因为2MB不是php无法处理的大文件。我的上传脚本是:
function uploadFile(){
if ( $this->error == 0 ){
if ( $this->destination == null ){
if ( $this->ext !== null || $this->ext !== '' ){
if ( in_array( $this->ext , $this->allowedExtensions ) ){
$tmp_file = $this->tmp_name;
if ( file_exists( $tmp_file ) ) {
$this->fileUid = md5(time());
move_uploaded_file($this->tmp_name, "/home/totalrec/upload/" . $this->fileUid.'.'.$this->ext);
return true;
} else {
$this->error = $tmp_file;
}
} else {
$this->error = 10;
}
} else {
$this->error = 9;
}
} else {
}
} else {
return false;
}
}
检查
php.ini
中的条目upload\u max\u filesize
(默认为2MB)、post\u max\u size
和内存限制
它们都必须比您试图上载的文件大。我可以看到upload\u max\u filesize是128 MB(php配置文件),但在cPanel上找不到post\u max\u大小。在哪里可以找到php.ini文件?如果找不到这些条目,请创建它们。但是如果您仅限于cPanel,恐怕您可能无法更改所需的任何配置。