简体   繁体   中英

I can't upload image to my database. I need to know the type of my image table in db

And this is my code, everything works good, everything is OK in my code. So I don't know what type should be my image table in database.

if(isset($_POST["title"]) && isset($_POST["content"]) && isset($_POST["order"])){
    $title = $_POST["title"];
    $content = $_POST["content"];
    $order = $_POST["order"];
    $image = $_FILES['image'] ;

    $title = addslashes($title);
    $content = addslashes($content);
    $order = (float)$order;
    $image = addslashes(file_get_contents($_FILES['image']['tmp_name'])) ;


    $sql = "INSERT INTO items (name,description,`price`, `image`) 
            VALUES ('$title','$content','$order', '{$image}')" ;

    mysqli_query($conn,$sql) or die('something wrong' . mysql_error());;
    echo mysqli_error($conn);

}

If you have any suggestions, please help, thank you

只需将图像放入文件夹中,并在db的列中插入图像的名称/ id,然后可以像html中那样以简单的代码调用它们,就像<img src="<?php $row['pathoftheimage'] /> ?> “> ,,,

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM