급하게 파일을 업로드하는 경우가 필요해서 간단하게 작성한 php 업로드 프로그램입니다.
1. 업로드 html 구성
- upload.html
<!DOCTYPE html>
<html>
<body>
<form action="uploader.php" method="post" enctype="multipart/form-data">
Select File:
<input type="file" name="fileToUpload"/>
<input type="submit" value="Upload file" name="submit"/>
</form>
</body>
</html>
2. upload file 처리를 위한 php 파일
- uploader.php
<?php
$target_path = "./uploads/";
$target_path = $target_path.basename( $_FILES['fileToUpload']['name']);
if(move_uploaded_file($_FILES['fileToUpload']['tmp_name'], $target_path)) {
echo "File uploaded successfully!";
} else{
echo "Sorry, file not uploaded, please try again!";
}
?>
주의 : 해당 방식은 모든 확장자 파일을 업로드하는 방식으로 파일 업로드 후, 실행할 수 있음, 이로 인해 보안에 많은 영향이 발생 가능함