Blueimp jQuery File Upload Integrated with Database

后端 未结 3 1127
孤城傲影
孤城傲影 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条回答
  •  Happy的楠姐
    2021-02-06 19:49

    Following this WIKI: https://github.com/blueimp/jQuery-File-Upload/wiki/Working-with-databases

    I setup uploads to be inserted into a database, then i changed my GET function as follows:

                public function get() {
                    $uploads = $this->query_db();
                    header('Content-type: application/json');
                    echo json_encode($uploads);
                }
    

    and my query_db function as follows:

             public function query_db() {
        $uploads_array = array();
        $select_result = $this->query("SELECT * FROM `uploads` ORDER BY `file_name`") or die(mysql_error());
        while($query_results = mysql_fetch_object($select_result))
            {   
                $file = new stdClass();
                $file->id = $query_results->id;
                $file->name = $query_results->file_name;
                $file->size = $query_results->file_size;
                $file->type = $query_results->file_type;
                $file->url = "http://files.domain.com/".$query_results->file_name;
                $file->thumbnail_url = "http://thumbnails.domain.com/".$query_results->file_name;
                $file->delete_url = "";
                $file->delete_type = "DELETE";
                array_push($uploads_array,$file);
            }
        return $uploads_array;
    }
    

提交回复
热议问题