ftp_put() 함수는 FTP 서버에 파일을 업로드합니다.
구문
ftp_put(con,remote_file,local_file,mode,beg_pos);
매개변수
-
콘 - FTP 연결
-
원격_파일 − 업로드할 파일 경로
-
local_fil − 업로드할 파일의 경로
-
모드 - 전송 모드. 다음은 가능한 값입니다 -
-
FTP_ASCII 또는
-
FTP_BINARY
-
-
beg_pos − 업로드 시작 위치
반환
ftp_put() 함수는 성공하면 TRUE를, 실패하면 FALSE를 반환합니다.
예시
다음은 서버에 파일을 업로드하는 예입니다 -
<?php
$ftp_server = "192.168.0.4";
$ftp_user = "tim";
$ftp_pass = "wthbn#@121";
$con = ftp_connect($ftp_server) or die("Could not connect to $ftp_server");
$login = ftp_login($con, $ftp_user, $ftp_pass);
$local_file = "localfile.txt";
$my_serverfile = "serverfile.txt";
if (ftp_put($ftp_conn, $my_serverfile, $local_file, FTP_ASCII)){
echo "File uploaded!";
} else {
echo "Error in uploading the file!";
}
// close
ftp_close($con);
?>