You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

47 lines
1.5 KiB

<?php
exit;
require_once "database.php";
if (isset($_POST['update'])) {
foreach ($_POST as $k => $v) {
$$k = htmlspecialchars(stripslashes(trim($v)));
}
//print_r($_POST);
//print_r($_FILES);exit;
$sql_atta = "";
if ($_FILES["attatch1"]["error"] == 0) {
$file_name = $_FILES["attatch1"]["name"];
$temp_file_name = $_FILES["attatch1"]["tmp_name"];
$file_size = $_FILES["attatch1"]["size"];
$target_dir = "public-forms/";
$target_file1 = strtolower($target_dir.basename($file_name));
$img_file_type = pathinfo($file_name, PATHINFO_EXTENSION);
$upload_ok = 1;
if (file_exists($target_file1)) unlink($target_file1);
$upload_res_1 = move_uploaded_file($temp_file_name, $target_file1);
$sql_atta .= "path = '$target_file1', ";
} else $target_file1 = "";
if ($target_file1 && !$upload_res_1) {
echo "<script type ='text/JavaScript'>";
echo "alert('檔案上傳失敗,請重新操作。');";
echo "location.href='forms-index.php';";
echo "</script>";
}
$db_query = "update form_list set title = '$title', ";
$db_query .= $sql_atta;
$db_query .= "seq = '$seq'";
$db_query .= "where id = '$id'";
$result = mysqli_query($link, $db_query);
mysqli_close($link);
echo "<script type ='text/JavaScript'>";
echo "alert('修改成功');";
echo "location.href='forms-index.php';";
echo "</script>";
}
?>