我需要帮助。请告诉我。
我使用 Blueimp jQuery 文件上传脚本,我添加了数据库连接,并添加了所有写入数据库文件的上传图像。如果您知道此脚本,当您再次打开上传页面时,脚本显示旧的上传文件
但我只需要显示我的property_id图像扩展 property_id='1' 我该怎么做?
我的基础设施是这样的
数据库表名:property_images
image_id property_id订单图像
11 1 图像.jpg
21 2 图像2.jpg
31 3 图像3.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
方法)完成的。将扫描程序替换为您的选择查询。然后,它会循环访问调用您提到的get_file_object
方法的结果。因此,get_file_objects
是您想要更改的方法。