这是HTML中的表单
<form method="post" action="reg.php" enctype="multipart/form-data">
<table width="100%" class="table4" cellpadding="0" cellspacing="0">
<tr>
<td align="right">Picture:</td>
<td><input type="file" id="pic1" name="pic1" /></td>
</tr>
</table>
<input type="submit" id="btnsubmit" name="btnsubmit" value="send" /></td>
</form>
在reg.php中
print "<pre>";
print_r($_FILES);
print "</pre>";
$pic1 = $_FILES['pic1']['name'];
$pic1_type = $_FILES['pic1']['type'];
$pic1_size = $_FILES['pic1']['size'];
但_FILES数组是空的:
Array
(
)
Notice: Undefined index: pic1 in reg.php on line 31
请帮忙!
我的文件是一个20kb的png文件,来自phpinfo():
file_uploads On On
max_file_uploads 20 20
post_max_size 10M 10M
upload_max_filesize 10M 10M
答案 0 :(得分:0)
我能想到唯一没有找到密钥的地方是:
file_uploads
已停用。上传的图像很可能超过服务器配置中定义的最大大小。您可以调用phpinfo()来检查当前的限制。
如果您想更改它们,只需根据需要修改php.ini上的以下属性:
; Maximum file size of post data that PHP will accept.
post_max_size = 20M
; Maximum allowed file size for uploaded files.
upload_max_filesize = 20M
或使用php_value within .htaccess:
php_value upload_max_filesize 100M
php_value post_max_size 100M