1. 在php.ini中,做如下修改:
file_uploads = on
upload_tmp_dir = /home/upload
upload_max_filesize = 4000M
post_max_size = 4000M
一般地,设置好上述四个参数后,上传<=8M的文件是不成问题,在网络正常的情况下。
但如果要上传>8M的大体积文件,只设置上述四项还一定能行的通。除非你的网络真有100M/S的上传高速,否则你还得关心关心下面的参数:
max_execution_time = 600
max_input_time = 600
memory_limit = 128M
2. 在要确认上传的 <form> 里加入以下行:
<input type="hidden" name="MAX_FILE_SIZE" value="4000000000">
3. $_FILES["userfile"]["error"]返回值说明:
$_FILES['teacher_pic']['error'] = 1 文件大小超过了PHP.ini中的文件限制
$_FILES['teacher_pic']['error'] = 2 文件大小超过了浏览器限制
$_FILES['teacher_pic']['error'] = 3 文件部分被上传
$_FILES['teacher_pic']['error'] = 4 没有找到要上传的文件
$_FILES['teacher_pic']['error'] = 5 服务器临时文件夹丢失
$_FILES['teacher_pic']['error'] = 6 文件写入到临时文件夹出错
$_FILES['teacher_pic']['error'] = -1 末充许的类型
$_FILES['teacher_pic']['error'] = -2 文件过大,上传文件不能超过{$this->maxSize}个字节
$_FILES['teacher_pic']['error'] = -3 上传失败
$_FILES['teacher_pic']['error'] = -4 建立存放上传文件目录失败,请重新指定上传目录
$_FILES['teacher_pic']['error'] = -5 必须指定上传文件的路径