压缩和图像使用codeigniter上传到上传文件夹中没有商店图像的表格

时间:2017-04-24 05:21:31

标签: php html codeigniter

使用codeigniter压缩和映像上传到数据库表,而不在上传文件夹中存储图像。我没有收到任何错误,但图片没有插入表格。有什么错吗?请建议我。

控制器

public function buyer_profile_image() {

        $file_type = $_FILES['image']['type'];

        $allowed = array("image/jpeg", "image/gif", "image/png");
        if (!in_array($file_type, $allowed)) {
            $this->load->view('buyerprofile'); 
        } else {
            $source_img = $_FILES['image']['tmp_name'];


            $destination_img = 'destination .jpg';


            $d = $this->compress($source_img, $destination_img, 50);


            $image = addslashes($d);
            $image = file_get_contents($image);
            $image = base64_encode($image);


            if ($image == "") {
                $_SESSION["errmsg"] = "please select image to post";
                $this->load->view('buyerprofile'); 
            } else {

                $data = array(

                    'profile_image' => $image,

                              );

                $this->Profile_model->Product_insert($data);

                 $this->load->view('buyerprofile'); 

            }
        }
    }

模型

public  function Product_insert($data){
$this->db->insert('siddu',$data);

查看页面

<form  action="<?php echo base_url(); ?>Index.php/Profile_cntrl/buyer_profile_image" method="post"  enctype="multipart/form-data">
                <div class="text-center profile-bg">
                    <div class="user-bg"></div>
                    <a href="#" class="user-img">
                        <img src="<?php echo base_url(); ?>images/prasanthi.jpg" class="img-circle img-user" alt="" width="100px;" height="100px;"/>
                    </a>
                    <div class="user-info">
                        <span class="">xxxxxxx</span>
                        <div class="user-location">
                            <i class="fa fa-map-marker"></i> Bangalore
                        </div>
                    </div>



                        <div class="change-profile">
                            <!--<span data-role="upload" class="upload-trigger"><i class="fa fa-plus"></i> Change Profile</span>-->
                            <div class="attachment">
                                <input type="file" name="image" id="image"/>



                            </div>
                                                    <input type="submit" value="upload" class="btn btn-success" style="width:70px;"> 

                        </div>

                </div>
                      </form>

0 个答案:

没有答案