-
Notifications
You must be signed in to change notification settings - Fork 1
/
endok_job.php
52 lines (43 loc) · 1.46 KB
/
endok_job.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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
<?php
//與資料庫連線
include("mysql.php");
mysqli_query($my_db,"SET NAMES 'utf8'");
//獲取變數
$cmpltdate=$_REQUEST["cmpltdate"];
$re_file=$_FILES["re_file"]["name"];
$ps=$_REQUEST["ps"];
$sql_id=$_REQUEST["sql_id"];
$closed=1;
//判斷是否有檔案上傳
if (empty($re_file)){
//如沒有檔案直接將資料存入
$sql="UPDATE document SET cmpltDate = '$cmpltdate', closed = '$closed' ,
ps ='$ps' WHERE id = '$sql_id'";
mysqli_query($my_db, $sql);
echo "<script>alert('結案成功');</script>";
header("REFRESH:0;url=user.php");
}else{
//如有檔案先判斷檔案是否錯誤
if ($_FILES["re_file"]["error"] === UPLOAD_ERR_OK){
//檢查檔案是否已經存在
if (file_exists("refile_upload/" . $re_file)){
echo "<script>alert('檔案已存在');</script>";
header("REFRESH:0;url=user.php");
} else {
$file = $_FILES["re_file"]["tmp_name"];
$re_file="reimg".$sql_id;
$dest = "refile_upload/" . $re_file;
//將檔案移至指定位置
move_uploaded_file($file, $dest);
//存入資料庫
$sql="UPDATE document SET cmpltDate = '$cmpltdate', closed = '$closed' ,
file2 = '$dest' , ps ='$ps' WHERE id = '$sql_id'";
mysqli_query($my_db, $sql);
echo "<script>alert('結案成功');</script>";
header("REFRESH:0;url=user.php");
}
} else {
echo "錯誤代碼:" . $_FILES["re_file"]["error"] . "<br/>";
}
}
?>