Blueimp jQuery File Upload Integrated with Database

后端 未结 3 1123
孤城傲影
孤城傲影 2021-02-06 19:17

This plugin reads image files on blueimproot/server/php/files on page load. I need to read records from database, and replace \'download\' HTML structure with m

3条回答
  •  一生所求
    2021-02-06 19:51

     public function get() {
        /*
        $file_name = isset($_REQUEST['file']) ?
            basename(stripslashes($_REQUEST['file'])) : null;
        if ($file_name) {
            $info = $this->get_file_object($file_name);
        } else {
            $info = $this->get_file_objects();
        }
        header('Content-type: application/json');
        echo json_encode($info);
        */
            $id_cat = $_REQUEST['catid'];
            $query = "SELECT id, name, price, img_path FROM products WHERE id_cat = $id_cat ORDER BY id";
            $prods = mysql_query($query);
    
            $prod_arr = array();
            while($prod = mysql_fetch_assoc($prods)) {
                //$prod_arr[] = $prod;
    
                $file = new stdClass();
                $file->name = "";// here image name goes i do not find image name in your select query
                $file->size = filesize($prod["img_path"]);// should be complete path
                $file->url =  $prod["img_path"];// should be relative path (http://localhost/images/234.jpg)
                $file->thumbnail_url = $prod["img_path"]; // thumbnail path
                $this->delete_type = "DELETE";
                $this->delete_url = ""; //here delete url you can delete image from database 
                array_push($prod_arr,$file);
            }
            header('Content-type: application/json');
        echo json_encode($prod_arr);
    }
    

提交回复
热议问题