-
Notifications
You must be signed in to change notification settings - Fork 0
/
action.php
38 lines (38 loc) · 1.04 KB
/
action.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
<?php
@$action = $_GET['act'];
if($action=='delimg'){
$filename = $_POST['imagename'];
if(!empty($filename)){
unlink('./upload/'.$filename);
echo '1';
}else{
echo '删除失败.';
}
}else{
$picname = $_FILES['mypic']['name'];
$picsize = $_FILES['mypic']['size'];
if ($picname != "") {
if ($picsize > 1024000*30) {
echo '图片大小不能超过30M';
exit;
}
$type = strstr($picname, '.');
if ($type != ".gif" && $type != ".jpg" && $type != ".png") {
echo '图片格式不对!';
exit;
}
$rand = rand(100, 999);
$pics = date("YmdHis") . $rand . $type;
//上传路径
$pic_path = "./upload/". $pics;
move_uploaded_file($_FILES['mypic']['tmp_name'], $pic_path);
}
$size = round($picsize/1024,2);
$arr = array(
'name'=>$picname,
'pic'=>$pics,
'size'=>$size
);
echo json_encode($arr);
}
?>