我有以下 php 代码,它允许用户上传图像。如何修改我的代码,以便对上传的图像大小有限制(比如说最大 20 k)。这是我的代码。
<?php
/// another code ///
if($_POST)
{
if(!isset($_FILES['mFile']))
{
//required variables are empty
die("Please add a image");
}
if($_FILES['mFile']['error'])
{
//File upload error encountered
die(upload_errors($_FILES['mFile']['error']));
}
$FileName = strtolower($_FILES['mFile']['name']);
$auto = mysql_real_escape_string($_POST['auto']);
$FileType = $_FILES['mFile']['type']; //file type
$FileSize = $_FILES['mFile']["size"]; //file size
if(move_uploaded_file($_FILES['mFile']["tmp_name"], $UploadDirectory . $NewFileName ))
{
mysql_query("INSERT INTO posts (title, post, img_name) VALUES ('$FileTitle', '$postURL', '$NewFileName')");
die('Thank you for your submission.');
}else{
die('There seems to be a problem. please try again.');
}
}
/// another code ///
?>