Computer >> 컴퓨터 >  >> 프로그램 작성 >> PHP

PHP의 move_uploaded_file() 함수

<시간/>

move_uploaded_file() 함수는 업로드된 파일을 새 위치로 이동합니다. 대상 파일이 이미 있는 경우 덮어씁니다.

구문

move_uploaded_file(file_path, moved_path)

매개변수

  • file_path - 이동할 파일입니다.

  • 이동 경로 - 파일이 이동할 위치입니다.

반환

move_uploaded_file() 함수는 성공하면 true를, 실패하면 false를 반환합니다.

예시

<?php
   if (move_uploaded_file($_FILES['userfile']['tmp_name'], "/documents/new/")) {
      print "Uploaded successfully!";
   } else {
      print "Upload failed!";
   }
?>

출력

Upload failed!PHP Notice: Undefined index: userfile in /home/cg/root/8944881/main.php on line 2