dongting7352 2014-04-17 12:17
浏览 78
已采纳

Blob数据类型图像未存储在数据库中

I am trying to store the image in database using the blob datatype.

but my program was not storing the image in database.

code:

form.php:

<form action="upload.php" method="post" enctype="multipart/form-data">
 File Name<input type="file" name="image" /><br />
 <input type="submit"  value="Upload" />
</form>

upload.php:

<?php
require_once('connection.php');

if(isset($_POST['submit'])){
    $image  =   addslashes(file_get_contents($_FILES[image]['tmp_name']));
    $query  =   "INSERT INTO images ('image') VALUES('".$image."')";
    mysql_query($query) or die(mysql_error());
    echo "Image id is ".mysql_insert_id();
    echo "Image id is ".mysql_insert_id();
}
?>

please resolve my problem..

  • 写回答

4条回答 默认 最新

  • dq13733519262 2014-04-17 12:26
    关注

    try to use the below code.

        $image  =   addslashes(file_get_contents($_FILES['image']['tmp_name']));
        $query  =   "INSERT INTO images (image) VALUES('".$image."')";
    

    i think this time its work fine...

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(3条)

报告相同问题?

悬赏问题

  • ¥15 2024-五一综合模拟赛
  • ¥15 下图接收小电路,谁知道原理
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度
  • ¥30 关于#r语言#的问题:如何对R语言中mfgarch包中构建的garch-midas模型进行样本内长期波动率预测和样本外长期波动率预测
  • ¥15 ETLCloud 处理json多层级问题
  • ¥15 matlab中使用gurobi时报错
  • ¥15 这个主板怎么能扩出一两个sata口
  • ¥15 不是,这到底错哪儿了😭