PHP and MySQL Web Development - P81

PHP and MySQL Web Development - P81: PHP and MySQL Web Development teaches the reader to develop dynamic, secure, commercial Web sites. Using the same accessible, popular teaching style of the first edition, this best-selling book has been updated to reflect the rapidly changing landscape of MySQL and PHP. | 372 Chapter 17 Using Network and Protocol Functions There are two modes for an FTP transfer ASCII and binary. The ASCII mode is used for transferring text files that is files that consist solely of ASCII characters and the binary mode used for transferring everything else. PHP s FTP library comes with two predefined constants FTP_ASCII and FTP_BINARY that represent these two need to decide which mode fits your file type and pass the corresponding constant to ftp_fget as the fourth parameter. In this case we are transferring a zip file and so we have used the FTP_BINARY mode. The ftp_fget function returns true if all goes well or false if an error is store the result in success and let the user know how it went. After the download has been attempted we close the local file using the fclose function. As an alternative to ftp_fget we could have used ftp_get which has the following prototype int ftp_get int ftp_connection string localfile_path string remotefile_path int mode This function works in much the same way as ftp_fget but does not require the local file to be pass it the system filename of the local file you would like to write to rather than a file handle. Note that there is no equivalent to the FTP command mget which can be used to download multiple files at a must instead make multiple calls to ftp_fget or ftp_get . Closing the Connection After we have finished with the FTP connection you should close it using the ftp_quit function ftp_quit conn You should pass this function the handle for the FTP connection. Uploading Files If you want to go the other way that is copy files from your server to a remote machine you can use two functions that are basically the opposite of ftp_fget and ftp_get . These functions are called ftp_fput and ftp_put .They have the following prototypes int ftp_fput int ftp_connection string remotefile_path int fp int mode int ftp_put int ftp_connection string remotefile_path string .

Không thể tạo bản xem trước, hãy bấm tải xuống
TỪ KHÓA LIÊN QUAN
TÀI LIỆU MỚI ĐĂNG
3    68    2    20-04-2024
Đã phát hiện trình chặn quảng cáo AdBlock
Trang web này phụ thuộc vào doanh thu từ số lần hiển thị quảng cáo để tồn tại. Vui lòng tắt trình chặn quảng cáo của bạn hoặc tạm dừng tính năng chặn quảng cáo cho trang web này.