我目前在上傳腳本時遇到了一些問題。 它不檢查文件類型是否允許,我不明白爲什麼。 有沒有人看到我的問題?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'包含了什麼? –