我目前在上传脚本时遇到了一些问题。 它不检查文件类型是否允许,我不明白为什么。 有没有人看到我的问题?PHP:图像检查扩展
//Reads the image name
$image=$_FILES['image']['name'];
//If empty
if ($image == "") {
echo '<div class="box_square form_error" style="margin-bottom:15px; padding:10px; font-size:11px;">Velg et bilde!</div>';
$errors = 1;
}
//If not empty
if ($image)
{
//Get orgiginal name from client machine
$filename = stripslashes($_FILES['image']['name']);
//Get the extension
$extension = getExtension($filename);
$extension = strtolower($extension);
//If file extension not known, error. If not, continue
if (($extension != "jpg") && ($extension != "jpeg"))
{
//Error message
echo '<div class="box_square form_error" style="margin-bottom:15px; padding:10px; font-size:11px;">Bare JPG og JPEG er tilatte filtyper!</div>';
$errors = 1;
}
发生了什么,你不想发生? –
当文件类型未知时,它不会回显消息。 – Kaizokupuffball
那么,'$ extension'包含了什么? –