无法将BLOB插入数据库。 PDO

时间:2016-04-20 12:55:26

标签: php pdo

我是PDO的新手,我正努力将图像(blob)插入数据库,插入表单中的其他信息。任何建议将不胜感激....谢谢

Heres what I have so far




  <form  enctype="multipart/form-data" action="create_post.php" method="POST" >
                        <div>
                            <input type="text" name="post_title" placeholder="Title">
                        </div>

                        <div>
                            <textarea name="post_description" placeholder="Description"></textarea> 
                        </div>

                        <div>
                        <input type="file" name="post_image" placeholder="image">
                        </div>

                        <div>
                        <input type="submit" />
                        </div>

                    </form>


      /////////php///////
    $sql = "INSERT INTO posts (post_title,post_description,posted_by,post_date) VALUES (:post_title, :post_description, :post_image, :posted_by, :post_date)
           ";
    $stmt = $db->prepare($sql);                 
    $stmt->bindParam(':post_title', $_POST['post_title'], PDO::PARAM_STR); 
    $stmt->bindParam(':post_description', $_POST['post_description'],     
    PDO::PARAM_STR); 
    $stmt->bindParam(':post_image',$blob,PDO::PARAM_LOB);
    $stmt->bindParam(':posted_by', $posted_by, PDO::PARAM_STR); 
    $stmt->bindParam(':post_date', $post_date, PDO::PARAM_STR); 
    $stmt->execute();

0 个答案:

没有答案
相关问题