PHP
downloads | documentation | faq | getting help | mailing lists | licenses | wiki | reporting bugs | php.net sites | links | conferences | my php.net

search for in the

PHP 입력/출력(input/output) 스트림> <HTTP 와 HTTPS
Last updated: Fri, 30 Jan 2009

view this page in

FTP 와 FTPS

PHP 4, PHP 5, PHP 6. PHP 4.3.0부터 ftps://

  • ftp://example.com/pub/file.txt
  • ftp://user:password@example.com/pub/file.txt
  • ftps://example.com/pub/file.txt
  • ftps://user:password@example.com/pub/file.txt

FTP를 통해 기존 파일에 대한 읽기 권한과 새로운 파일의 생성 권한을 허용한다. 서버가 패시브 모드(passive mode) ftp를 지원하지않으면, 접속이 실패할것이다.

읽거나 쓰기 위해 파일을 열수 있다. 그러나 동시에 읽기/쓰기를 할수 없다. 원격 파일이 ftp 서버에 이미 존재하고 그 파일에 쓰기를 시도하려하는데 컨텍스트 옵션 overwrite를 설정하지 않았다면, 접속이 실패할것이다. ftp를 통해서 존재하는 파일을 덮어쓰려면, overwrite 옵션을 설정하고 파일을 쓰기 모드로 열어야 합니다. 차선책으로 FTP 확장을 사용할수 있다.

Note: 덧붙이기
PHP 5.0.0부터 ftp:// URL 래퍼를 통해서 파일을 덧붙일 수 있습니다. 이전 버전에서, ftp://를 통한 파일 덧붙이기는 실패합니다.

PHP 4.3.0부터 ftps://를 지원한다. ftp://와 동일하지만, ftp 서버를 통해 안전한 접속 협상(negotiate)을 시도하려 한다. 서버가 SSL을 지원하지 않으면, 접속은 원래의 인코딩되지 않는 ftp로 되돌아간다.

Note: FTPS는 PHP 4.3.0부터 지원되었다. OpenSSL을 지원하도록 컴파일되어야 한다.

래퍼 요약
속성 PHP 4 PHP 5
allow_url_fopen으로 제한
읽기 허용
쓰기 허용 Yes (새 파일만) Yes (새 파일/overwrite 로 기존 파일)
추가 허용 아니오
동시 읽기/쓰기 허용 아니오 아니오
stat() 지원 아니오 PHP 5.0.0에서: filesize(), filetype(), file_exists(), is_file(), is_dir() 요소만. PHP 5.1.0에서: filemtime().
unlink() 지원 아니오
rename() 지원 아니오
mkdir() 지원 아니오
rmdir() 지원 아니오



PHP 입력/출력(input/output) 스트림> <HTTP 와 HTTPS
Last updated: Fri, 30 Jan 2009
 
add a note add a note User Contributed Notes
FTP 와 FTPS
fazil dot stormhammer dot nospam at gmail dot com
25-Apr-2008 11:41
Document says "Allows read access to existing files and creation of new files via FTP. If the server does not support passive mode ftp, the connection will fail. "

As of version 5.2.5 at least fopen("ftp://...") uses an ACTIVE mode connection by default (it issues an FTP PORT command but not a PASV command).  To force passive mode:

$f = fopen("ftp://...");
ftp_pasv($f, true);
wlangdon at essex dot ac dot uk
09-Oct-2006 07:32
old fashioned FTP servers may not be compatible with ftp_connect().
26-Sep-2005 06:33
<?
$str
="replace all contenents";
$filew="ftp://gufo:gufo@192.168.1.55:21/jj.php";
$opts = array('ftp' => array('overwrite' => true));
$context = stream_context_create($opts);
$strwri = file_put_contents($filew,$str,LOCK_EX,$context);
?>
php at f00n dot com
04-Jul-2004 10:39
For Intranet purposes I found I preferred to move my file via ftp functions to match the session user's ftp account and put the file in a holding bay so I knew who it was from.

The FTP wrapper method will NOT do this if your ftp server does NOT support passive mode.

eg.  an ftp server behind NAT/routing

PHP 입력/출력(input/output) 스트림> <HTTP 와 HTTPS
Last updated: Fri, 30 Jan 2009
 
 
show source | credits | sitemap | contact | advertising | mirror sites