BLOG main image
개발괴발's Blog
개발괴발





PHP 간단한 파일 업로드 upload

홈페이지제작 2012. 7. 19. 07:22 by 개발괴발 | 세상의 모든 정보 | hotrain@hanmail.net

PHP 간단하게 파일 업로드 하기 (File Upload)


<?

if($mode=="upload") {

$t_dir = "../target_dir"; // 업로드된 파일을 저장할 디렉토리

$s_sm = "savename"; // 업로드된 파일을 저장할 이름 ($file1_name 이라고 하면 PC에서의 원 파일명을 받아옵니다.)

if($file1){

$ret = move_uploaded_file($file1, "$t_dir/$s_sm");

if($ret) {

echo "파일 업로드 완료";

} else {

echo "파일 업로드 실패";

}

}

}

?>

<form method=post enctype='multipart/form-data'>

<input type=hidden name=mode value=upload>

<input type=file name=file1>

<input type=submit>

</form>


간단하게 이용할 수 있는 업로드 소스 예제 입니다,

참고로, 파일을 업로드 하려면 폼에서 enctype의 값을 multipart/form-data로 해야 합니다.

실제로 파일을 업로드 하는 부분은 move_uploaded_file 부분입니다. 


간단한 도해

PHP 파일 업로드 uploadPHP 파일 업로드 upload




 
 

카테고리

분류 전체보기 (239)
홈페이지제작 (61)
사진 (53)
일반 (9)
발자국 (58)
경기도 광명 (18)

최근에 올라온 글

최근에 달린 댓글

최근에 받은 트랙백

달력

«   2024/04   »
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

글 보관함