我有一张上传图片的表单:
<form action="" method="post" enctype="multipart/form-data">
<input type="file" name="imgUpload" class="admin_img_txt">
<input type="submit" value="Upload" name="img01" class="admin_img_btn">
</form>
它使用img01
帖子中包含的代码发布到自己。该过程有效,但当我回显$_FILES
数组时,我没有文件大小。我上传的图片是我在本地计算机上的有效jpg。它返回
(
[imgUpload] => Array
(
[name] => testjpg.jpg
[type] => image/jpeg
[tmp_name] => /tmp/php3TxfDe
[error] => 0
[size] => 0
)
)
我已经验证了php.ini文件的设置。它允许最多8mb的文件,这是远远不够的。有任何想法吗?提前谢谢。
编辑:这是php。我并没有把它包含在print_r之前,所以我认为它并不重要。if(isset($_POST["img01"])) {
echo '<pre>';
print_r($_FILES);
echo '</pre>';
$filename = $_FILES["imgUpload"]["name"];
$file_basename = substr($filename, 0, strripos($filename, '.'));
$file_ext = substr($filename, strripos($filename, '.'));
$ven_imgname = "$ven_id" . "_001";
$newfilename = md5($ven_imgname) . $file_ext;
$filesize = $_FILES["imgUpload"]["size"];
$allowed_file_types = array('.jpg','.jpeg','.gif');
if (in_array($file_ext,$allowed_file_types) && ($filesize < 200000)) {
if (file_exists("../img/venues/$ven_imgname.$file_ext")) {
echo "You have already uploaded this file - $ven_imgname.$file_ext";
} else {
move_uploaded_file($_FILES["imgUpload"]["temp_name"], "../img/venues/" . $newfilename);
echo "File uploaded successfully.";
}
} else {
echo "File upload failed.";
}
}