[英]Blueimp jQuery File Upload - list images from database
I need help for this.我需要这方面的帮助。 Please advise me.
请建议我。
I use Blueimp jQuery File Upload script and I add database connection and I add all upload images write in db file.我使用 Blueimp jQuery 文件上传脚本并添加数据库连接,并将所有上传图像添加到 db 文件中。 If you know this script when you open upload page again script show old uploaded files
如果您在再次打开上传页面时知道此脚本脚本显示旧上传的文件
but i need only show my property_id images expample property_id='1' how can I do that?但我只需要显示我的 property_id 图像示例property_id='1'我该怎么做?
My infrastructure is like this我的基础设施是这样的
db table name: property_images数据库表名:property_images
image_id property_id order image image_id property_id 订单图片
1 1 1 image.jpg 1 1 1 图片.jpg
2 1 2 image2.jpg 2 1 2 image2.jpg
3 1 3 image3.jpg 3 1 3 image3.jpg
4 2 1 image.jpg 4 2 1 图片.jpg
//------------ this code part write all images in database------------------------------ //------------ 此代码部分写入数据库中的所有图像---------------------------- ——
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;
}
I think this script use this codes for image listing but how can be change this code我认为此脚本使用此代码进行图像列表,但如何更改此代码
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;
}
The listing is done through the get_file_objects
method (which uses the scandir
method).清单是通过
get_file_objects
方法(使用scandir
方法)完成的。 Replace the scandir with your select query.用您的选择查询替换 scandir。 It then iterates over the result calling the
get_file_object
method you mentioned.然后它调用您提到的
get_file_object
方法迭代结果。 So the get_file_objects
is the method you'll want to alter.所以
get_file_objects
是你想要改变的方法。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.