php

ftp 관련

하나에하나 2014. 10. 15. 13:33

여기 회사에서 계속 일하게 된다면 아마도 현장 슬라이드 받는 문제가 생길 것 같다.

 

그때 참조하려고. - ftp 서버를 만들기 위해서는 파일질라 서버, 알드라이브 서버를 활용하면 될듯. 서버 프로그램이 은근 많음.

 

php ftp 함수 모음

 

출처 : http://firejune.com/1332/PHP%EC%97%90%EC%84%9C+FTP%ED%95%A8%EC%88%98%EC%9D%98++%EC%A2%85%EB%A5%98%EC%99%80++%EC%82%AC%EC%9A%A9%EB%B2%95

 

구글링 : php ftp 파일 업로드   도 참고할 자료가 꽤 될 듯.

 

 

 

 

 

 

 

 

 

1. ftp_connect : FTP서버에 연결한다.

int ftp_connect (string host [, int port]) 
$ftp = ftp_connect("서버주소 또는 도메인명", 21); 

2. ftp_login : 계정과 패스워드로 서버에 접근한다.

int ftp_login (int ftp_stream, string username, string password) 
$ftplogin = ftp_login($ftp, "$ftp_user_name", "$ftp_user_pass");

3. ftp_pwd : 현재 디렉토리 값을 리턴한다.

int ftp_pwd (int ftp_stream) 
$ftp_dir = $ftp_pwd($ftp); 

4. ftp_cdup : 가장 상위 디렉토리로 이동

int ftp_cdup (int ftp_stream) 
$ftp_dir = $ftp_cdup($ftp); 

5. ftp_chdir : FTP 디렉토리의 변경

int ftp_chdir (int ftp_stream, string directory) 
$chdir = ftp_chdir($ftp, $ftp_dir); 

6. ftp_mkdir : 디렉토리를 만들고 만든 디렉토리명을 반환한다.

string ftp_mkdir (int ftp_stream, string directory) 
$mkdir = ftp_mkdir($ftp, "만들 디렉토리명");

7. ftp_rmdir : 디렉토리를 삭제한다.

int ftp_rmdir (int ftp_stream, string directory) 
$mkdir = ftp_rmdir($ftp,"삭제할 디렉토리명");

8. ftp_nlist : 디렉토리의 파일이름을 배열로 반환한다.

int ftp_nlist (int ftp_stream, string directory) 
$contents = ftp_nlist($ftp, "디렉토리명");

9. ftp_rawlist : 디렉토리의 파일이름과 읽고 쓰고 실행할 권한을 파일 당 한 줄의 배열로 반환한다.

int ftp_rawlist (int ftp_stream, string directory) 
$contents = ftp_rawlist($ftp, "디렉토리명");

10. ftp_systype : FTP서버의 타입을 리턴하는데 리눅스는 UNIX로 표시해준다.

int ftp_systype (int ftp_stream) 
echo ftp_systype($ftp);

11. ftp_get : FTP로부터 파일을 다운로드 받는다.

int ftp_get (int ftp_stream, string local_file, string remote_file, int mode) 
$download = ftp_get($ftp, "저장할 파일명", "다운받을 파일명","FTP_ASCII or FTP_BINARY");

12. ftp_fget : FTP로부터 파일 포인터를 다운받는다.

int ftp_fget (int ftp_stream, int fp, string remote_file, int mode) 
$download = ftp_fget($ftp, "저장할 파일명", "다운받을 파일명", "FTP_ASCII or FTP_BINARY");

13. ftp_put : FTP서버에 파일을 업로드 한다.

int ftp_put (int ftp_stream, string remote_file, string local_file, int mode) 
$upload = ftp_put($ftp, "업로드할 파일명", "업로드될 파일명", "FTP_ASCII or FTP_BINARY");

14. ftp_fput : FTP서버에 파일 포인터를 업로드한다.

int ftp_fput (int ftp_stream, string remote_file, string local_file, int mode) 
$upload = ftp_fput($ftp, "업로드할 파일명", "업로드될 파일명", "FTP_ASCII or FTP_BINARY");

15. ftp_size : 파일의 사이즈를 구한다.

int ftp_size (int ftp_stream, string remote_file) 
$filesize = ftp_size($ftp, $contents[$i]);

ftp_nlist 나 ftp_rawlist에 의해 구한 파일명에 대한 배열값인 $contents[$i]에는 각 파일명과 속성이 저장되어지는데 이 파일명을 사이즈로 구하면 파일이면 사이즈가 리턴되고 디렉토리이면 -1이 리턴된다.

16. ftp_mdtm : 파일의 마지막 수정시간을 timestamp 값으로 리턴한다.

int ftp_mdtm (int ftp_stream, string remote_file) 
$filemdth = ftp_size($ftp, "파일명");

17. ftp_rename : 파일명을 변경한다.

int ftp_rename (int ftp_stream, string from, string to) 
$rename = ftp_rename($ftp, "바꿀 파일명", "바뀐 후 파일명");

18. ftp_delete : 해당 파일을 삭제한다.

int ftp_delete (int ftp_stream, string path) 
$delfile = ftp_delete($ftp, "지울 파일명");

19. ftp_quit : 연결된 FTP의 접속을 끊는다.

int ftp_quit (int ftp_stream) 
ftp_quit ($ftp);

출처: ?

'php' 카테고리의 다른 글

php 이메일 유효성 체크 (정규표현식)  (0) 2015.05.20
문자열 중 일부를 * 표시로 가리기  (0) 2015.05.20
숫자 한글 변화 - php / javascript  (0) 2013.08.13
mpdf  (0) 2011.10.06
CodeIgniter   (0) 2011.10.06