php 在用POST上传文件时,系统默认上传限制为2M,POST方法也有限制默认为8M
;;;;;;;;;;;;;;;;
; File Uploads ;
;;;;;;;;;;;;;;;;
; Whether to allow HTTP file uploads.
file_uploads = On
; Temporary directory for HTTP uploaded files (will use system default if not
; specified).
upload_tmp_dir = "D:/wamp/tmp"
; Maximum allowed size for uploaded files.
upload_max_filesize = 2M
;;;;;;;;;;;;;;;;;
; Data Handling ;
;;;;;;;;;;;;;;;;;
; Maximum size of POST data that PHP will accept.
post_max_size = 8M
所以在利用POST方法上传文件时要更改这两个限制才能上传指定大小的文件 <?php
if($_POST[action]=="uploadImage"){
//echo $_File[filename][name]."上传图片";
if(!empty($_FILES[up_picture][name])){//判断上传内容是否为空
if($_FILES[up_picture][error]>0){
echo "上传错误";
switch ($_FILES[up_picture][error]){
case 1:
echo "上传文件大小超过配置文件规定";
break;
case 2:
echo "上传文件大小超过表单中约定值";
break;
case 3:
echo "上传文件不全";
break;
case 4:
echo "没有上传文件";
break;
}
}else{
if(!is_dir("./upfile/")){
mkdir("./upfile/");
}
$path='./upfile/'.time().strstr($_FILES[up_picture][name],'.');//定义文件名称和存储位置
if(is_uploaded_file($_FILES[up_picture][tmp_name])){//判断是否是HTTP POST上传
if(!move_uploaded_file($_FILES[up_picture][tmp_name], $path)){//执行上传
echo "上传失败";
}else{
echo "文件".time().$_FILES[up_picture][name]."上传成功,大小为:".$_FILES[up_picture][size]."字节";
}
}else{
echo "上传文件".$_FILES[up_picture][name]."不合法";
}
}
}else{
echo "上传内容为空";
}
}