簡體   English   中英

Blueimp jQuery 文件上傳 - 從數據庫中列出圖像

[英]Blueimp jQuery File Upload - list images from database

我需要這方面的幫助。 請建議我。

我使用 Blueimp jQuery 文件上傳腳本並添加數據庫連接,並將所有上傳圖像添加到 db 文件中。 如果您在再次打開上傳頁面時知道此腳本腳本顯示舊上傳的文件

我只需要顯示我的 property_id 圖像示例property_id='1'我該怎么做?

我的基礎設施是這樣的

數據庫表名:property_images

image_id property_id 訂單圖片

1 1 1 圖片.jpg

2 1 2 image2.jpg

3 1 3 image3.jpg

4 2 1 圖片.jpg

//------------ 此代碼部分寫入數據庫中的所有圖像---------------------------- ——

function query($query) {
$database = $this->options['database'];
$host = $this->options['host'];
$username = $this->options['username'];
$password = $this->options['password'];
$link = mysql_connect($host,$username,$password);
if (!$link) {
die(mysql_error());
}
$db_selected = mysql_select_db($database);
if (!$db_selected) {
die(mysql_error());
}
$result = mysql_query($query);
mysql_close($link);
return $result;
}
function add_img($whichimg)
{
    $property_id= $_POST['property_id'];
$add_to_db = $this->query("INSERT INTO property_images (image,property_id) VALUES ('".$whichimg."','".$property_id."')") or die(mysql_error());
return $add_to_db;
}
function delete_img($delimg)
{
$delete_from_db = $this->query("DELETE FROM property_images WHERE image = '$delimg'") or die(mysql_error());
return $delete_from_db;
}

我認為此腳本使用此代碼進行圖像列表,但如何更改此代碼

protected function get_file_object($file_name) {
    if ($this->is_valid_file_object($file_name)) {
        $file = new stdClass();
        $file->name = $file_name;
        $file->size = $this->get_file_size(
            $this->get_upload_path($file_name)
        );
        $file->url = $this->get_download_url($file->name);
        foreach($this->options['image_versions'] as $version => $options) {
            if (!empty($version)) {
                if (is_file($this->get_upload_path($file_name, $version))) {
                    $file->{$version.'_url'} = $this->get_download_url(
                        $file->name,
                        $version
                    );
                }
            }
        }
        $this->set_file_delete_properties($file);
        return $file;
    }
    return null;
}

清單是通過get_file_objects方法(使用scandir方法)完成的。 用您的選擇查詢替換 scandir。 然后它調用您提到的get_file_object方法迭代結果。 所以get_file_objects是你想要改變的方法。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM