如果图像字段为空,则应接受数据

I am writing the query to accept image field only svg,png,jpeg format.But if the image field is empty it is displaying as error while uploading,actually it should insert the remaining fields like name and all if I am not adding image also.Here is my query.

example.php

$title=$_POST['blog_title'];
$result = str_replace(" ", "-", $title);
$description=$_POST['blog_description'];
if(is_uploaded_file($_FILES['image']['tmp_name'])){
$name=$_FILES["image"]["name"];
$type=$_FILES["image"]["type"];
$size=$_FILES["image"]["size"];
$temp=$_FILES["image"]["tmp_name"];
$error=$_FILES["image"]["error"];
$ext = strtolower(pathinfo($name, PATHINFO_EXTENSION));
if($error > 0){
    die("error while uploading");
}else{
    $permissible_extension = array("png", "jpg", "jpeg", "svg", "jpg","jpe");
    if(in_array($ext, $permissible_extension)){
        if(move_uploaded_file($temp,"upload/".$name)){
            $sql = mysql_query("INSERT INTO blogs(image,blog_title,blog_description)values('$name','$result','$description')");
            if($sql){
                header("Location:blogimage.php");  
                exit();
            }else{
                echo "Insertion failed";
            }
        }else{
            echo "File couldn't be uploaded";
        }
    }else{
        echo "Invalid format";
    }
}
}else{
$sql = mysql_query("INSERT INTO blogs(blog_title,blog_description)values('$result','$description')");
if($sql){
    header("Location:blogimage.php");  
    exit();
}else{
    echo "Insertion failed";
}
}

Firstly, mandatory advice against the use of mysql_* functions. This is deprecated, use mysqli_* functions or PDO instead.

Now, your issue. If you want to store the other informations about the file even when the filetype is empty or wrong, you will need to do your INSERT before the test.

Below are some code to you try:

<?php
//connect to the database using mysqli
$name=$_FILES["image"]["name"];
$type=$_FILES["image"]["type"];
$size=$_FILES["image"]["size"];
$temp=$_FILES["image"]["tmp_name"];
$error=$_FILES["image"]["error"];
if($error>0)
    die("error while uploading");
else
{
    //Insert the informations in your database here, so even without the upload, the info about the file will be stored
    $query = mysqli_query("INSERT INTO blogs(image)values('$name')");
    if($type == "image/png" || $type == "image/jpg"|| $type == "image/jpeg" || $type == "image/svg" || $type == "image/jpe" || $type==" ")
    {
        move_uploaded_file($temp,"upload/".$name);
        echo "upload complete"; 
    }
    else
    {   
        die("Format not allowed or file size too big!");
    }
}