<?php
session_start();
if (isset($_SESSION["userid"])) $userid = $_SESSION["userid"];
else $userid = "";
if (isset($_SESSION["username"])) $username = $_SESSION["username"];
else $username = "";
if (isset($_SESSION["userpass"])) $userpass = $_SESSION["userpass"];
else $userpass = "";
$old_title_name = $_POST["old_title_name"];
$new_title_name = $_POST["title_name"];
$genre = $_POST["genre"];
$introduction = $_POST["introduction"];
$regist_day = date("Y-m-d (H:i)"); // 현재의 '년-월-일-시-분'을 저장
$upload_dir = './img/';
$upfile_name = $_FILES["upfile"]["name"];
$upfile_tmp_name = $_FILES["upfile"]["tmp_name"];
$upfile_type = $_FILES["upfile"]["type"];
$upfile_size = $_FILES["upfile"]["size"];
$upfile_error = $_FILES["upfile"]["error"];
if ($upfile_name && !$upfile_error)
{
$file = explode(".", $upfile_name);
$file_name = $file[0];
$file_ext = $file[1];
$new_file_name = date("Y_m_d_H_i_s");
$new_file_name = $upfile_name.$new_file_name;
$copied_file_name = $new_file_name.".".$file_ext;
$uploaded_file = $upload_dir.$copied_file_name;
if( $upfile_size > 20000000 ) { //20메가
echo("
<script>
alert('업로드 파일 크기가 지정된 용량(20MB)을 초과합니다!<br>파일 크기를 체크해주세요! ');
history.go(-1)
</script>
");
exit;
}
if (!move_uploaded_file($upfile_tmp_name, $uploaded_file) )
{
echo("
<script>
alert('파일을 지정한 디렉토리에 복사하는데 실패했습니다.');
history.go(-1)
</script>
");
exit;
}
}
$con = mysqli_connect("localhost", "user1", "12345", "testdb");
//DB 연결 후 한글코드 세팅
mysqli_set_charset($con, 'utf8');
$sql = "update uploadnovel set title_name='$new_title_name', genre='$genre' , upfile_name='$upfile_name', upfile_type='$upfile_type', file_copied='$file_copied', introduction='$introduction', where id='$id' AND title_name='$old_title_name'";
mysqli_query($con, $sql);
mysqli_close($con);
echo "
<script>
location.href = 'test.php';
</script>
";
?>
php.ini를 건들여서 오류는 안나지만 적용이 되지 않습니다... ㅠㅠ
답변 3개
답변을 작성하려면 로그인이 필요합니다.