IT/php

php ftp_fput - 열린 파일에서 FTP 서버로 업로드

조원태 2017. 2. 13. 01:16
반응형

ftp_fput - 열린 파일에서 FTP 서버로 업로드


설명 ¶


bool ftp_fput ( resource $ftp_stream , string $remote_file , resource $handle , int $mode [, int $startpos= 0 ])

ftp_fput () 은 파일 포인터에서 FTP 서버의 원격 파일로 데이터를 업로드합니다.


매개 변수 ¶


ftp_stream

FTP 연결의 링크 식별자입니다.


remote_file

원격 파일 경로입니다.


handle

로컬 파일에 열린 파일 포인터. 파일의 끝에서 읽기가 중지됩니다.


mode

전송 모드. FTP_ASCII또는 중 하나 여야합니다 FTP_BINARY.


startpos

업로드를 시작할 원격 파일의 위치입니다.


반환 값 ¶


반환 값 TRUE성공 또는 FALSE실패.


예 ¶


Example # 1 ftp_fput () 예제


<?php


// open some file for reading

$file = 'somefile.txt';

$fp = fopen($file, 'r');


// set up basic connection

$conn_id = ftp_connect($ftp_server);


// login with username and password

$login_result = ftp_login($conn_id, $ftp_user_name, $ftp_user_pass);


// try to upload $file

if (ftp_fput($conn_id, $file, $fp, FTP_ASCII)) {

    echo "Successfully uploaded $file\n";

} else {

    echo "There was a problem while uploading $file\n";

}


// close the connection and the file handler

ftp_close($conn_id);

fclose($fp);


?>

반응형