PHP FTP Functions

Introduksiyon sa PHP FTP

Ang mga FTP function ay nagbibigay ng access sa client sa file server sa pamamagitan ng file transfer protocol (FTP).

Ang mga FTP function ay ginagamit para sa pagbubukas, paglog-in at pagbubukas ng koneksyon, gayundin para sa pag-upload, pag-download, pagpangalanan, pagtanggal at pagkuha ng impormasyon ng mga file sa file server. Hindi lahat ng FTP function ay gumagana o nagbibigay ng katulad na resulta para sa bawat server. Mula sa PHP 3, ang FTP function ay magagamit.

Ang mga function na ito ay ginagamit para sa detalyadong pagpasok sa FTP server. Kung ikaw ay nais lamang ng pagbabasa at pagsulat sa FTP server, inirerekomenda gamitin ang ftp:// wrapper sa Filesystem function.

I-install

Ang bersyon ng PHP sa Windows ay may in-built na suporta para sa modulong FTP extension. Hindi kailangan ng anumang karagdagang library ng ekspansyon para gamitin ang mga function na ito.

Gayunpaman, kung gumagamit ka ng bersyon ng PHP sa Linux, magdagdag ng opsyon --enable-ftp (PHP 4 o higit pa) o --with-ftp (PHP 3 bersyon) sa panahon ng pagkompilasyon.

PHP FTP Functions

PHP:I-indikahin ang pinakamaagang bersyon ng PHP na sumusuporta sa function na ito.

Function Description PHP
ftp_alloc() I-allocate space para sa file na i-upload sa FTP server. 5
ftp_cdup() I-baguhin ang kasalukuyang direktoryo sa magulang na direktoryo sa FTP server. 3
ftp_chdir() I-baguhin ang kasalukuyang direktoryo sa FTP server. 3
ftp_chmod() I-set ang mga kapangyarihan ng file sa FTP. 5
ftp_close() I-close ang FTP koneksyon. 4
ftp_connect() I-open ang FTP koneksyon. 3
ftp_delete() I-delete ang file sa FTP server. 3
ftp_exec() I-execute ang isang programa/komando sa FTP. 4
ftp_fget() I-download ang file mula sa FTP server at i-save ito sa lokal na bukas na file. 3
ftp_fput() I-upload ang bukas na file at i-save ito sa FTP server bilang isang file. 3
ftp_get_option() Nagpalabas ng iba't ibang opsyon sa kasalukuyang FTP koneksyon. 4
ftp_get() I-download ang file mula sa FTP server. 3
ftp_login() Mag-log in sa FTP server. 3
ftp_mdtm() Nagpalabas ng kasalukuyang oras ng pagbabago ng tinukoy na file. 3
ftp_mkdir() Magtatayo ng bagong direktoryo sa FTP server. 3
ftp_nb_continue() Magpatuloy sa pagkuha at magpadala ng file (non-blocking). 4
ftp_nb_fget() I-download ang file mula sa FTP server at i-save ito sa lokal na bukas na file (non-blocking). 4
ftp_nb_fput() I-upload ang bukas na file at i-save ito sa FTP server bilang isang file (non-blocking). 4
ftp_nb_get() I-download ang file mula sa FTP server (non-blocking). 4
ftp_nb_put() I-upload ang file sa server (non-blocking). 4
ftp_nlist() Nagpalabas ng listahan ng mga file sa tinukoy na direktoryo. 3
ftp_pasv() Nagpalabas kung ang kasalukuyang FTP ay bukas sa pagpapatupad ng passive mode. 3
ftp_put() Upload a file to the server. 3
ftp_pwd() Returns the current directory name. 3
ftp_quit() Alias for ftp_close() 3
ftp_raw() Send a raw command to the FTP server. 5
ftp_rawlist() Returns a detailed list of files in the specified directory. 3
ftp_rename() Rename a file or directory on the FTP server. 3
ftp_rmdir() Delete a directory on the FTP server. 3
ftp_set_option() Set various FTP runtime options. 4
ftp_site() Send a SITE command to the server. 3
ftp_size() Returns the size of the specified file. 3
ftp_ssl_connect() Open a secure SSL-FTP connection. 4
ftp_systype() Returns the system type identifier of the remote FTP server. 3

PHP FTP Constants

PHP:Indicates the earliest PHP version that supports the constant.

Constants Description PHP
FTP_ASCII   3
FTP_TEXT   3
FTP_BINARY   3
FTP_IMAGE   3
FTP_TIMEOUT_SEC   3
FTP_AUTOSEEK   4
FTP_AUTORESUME

Automatically decide the recovery and start position for GET and PUT requests

Can only work when FTP_AUTOSEEK is open

4
FTP_FAILED Asynchronous transfer failed 4
FTP_FINISHED Asynchronous transfer successful 4
FTP_MOREDATA Asynchronous transfer is in active state 4