How to upload images into MySQL database using PHP code

前端 未结 3 1932
清酒与你
清酒与你 2020-11-22 15:21

I am trying to save images in my database from HTML form. I have written PHP code to accomplish this task. The program is not generating any error message, but also not inse

3条回答
  •  粉色の甜心
    2020-11-22 15:58

    Just few more details

    • Add mysql field

    `image` blob

    • Get data from image

    $image = addslashes(file_get_contents($_FILES['image']['tmp_name']));

    • Insert image data into db

    $sql = "INSERT INTO `product_images` (`id`, `image`) VALUES ('1', '{$image}')";

    • Show image to the web

    • End

提交回复
热议问题