diff --git a/admin/pics.php b/admin/pics.php
index 036cc08..ddd8a2e 100644
--- a/admin/pics.php
+++ b/admin/pics.php
@@ -30,10 +30,10 @@
-
+
|
|
- 删除 |
+ 删除 |
@@ -56,17 +56,22 @@
});
}
//删除图片
- function delimg(){
- layer.confirm('纳尼?', {
- btn: ['按钮一', '按钮二', '按钮三'] //可以无限个按钮
- ,btn3: function(index, layero){
- //按钮【按钮三】的回调
- }
- }, function(index, layero){
- //按钮【按钮一】的回调
- }, function(index){
- //按钮【按钮二】的回调
- });
+ function delimg(id){
+ var msg = "确认删除?";
+ var id = id;
+ if (confirm(msg)==true){
+ $.get("../api/delete.php?id="+id,function(data,status){
+ //删除成功
+ if(data == 'ok') {
+ $("#row"+id).remove();
+ }
+ else{
+ alert(data); //删除失败,弹出报错
+ }
+ });
+ }else{
+ return false;
+ }
}
\ No newline at end of file
diff --git a/api/PublicClass.php b/api/PublicClass.php
new file mode 100644
index 0000000..1cf1130
--- /dev/null
+++ b/api/PublicClass.php
@@ -0,0 +1,17 @@
+uid;
+ $loginid = $this->login;
+ if($uid != $loginid) {
+ return false;
+ echo '权限不足';
+ exit;
+ }
+ }
+
+ }
+?>
\ No newline at end of file
diff --git a/api/delete.php b/api/delete.php
new file mode 100644
index 0000000..ef6588c
--- /dev/null
+++ b/api/delete.php
@@ -0,0 +1,38 @@
+get("uploads",["id","dir"],["id" => $id]);
+
+ //如果查询到了ID
+ if($imginfo) {
+ //如果文件删除成功
+ if(unlink("../".$imginfo['dir'])) {
+ //删除数据库记录
+ $delinfo = $database->delete("uploads",["id" => $id]);
+ if($delinfo) {
+ echo 'ok';
+ }
+ else{
+ echo '数据库删除失败';
+ exit;
+ }
+ }
+ else{
+ echo '删除失败,可能是文件不存在';
+ }
+ }
+ else {
+ echo 'ID不存在';
+ exit;
+ }
+?>
\ No newline at end of file
diff --git a/api/functions.php b/api/functions.php
new file mode 100644
index 0000000..370b232
--- /dev/null
+++ b/api/functions.php
@@ -0,0 +1,3 @@
+
\ No newline at end of file