Giới thiệu
Tùy chọn ngữ cảnh cho ftp:// và ftps://:
| overwrite | Cho phép ghi đè file đã tồn tại trên server từ xa khi tải lên. |
| resume_pos | Vị trí offset file bắt đầu truyền. Chỉ áp dụng tải xuống. Mặc định 0 (đầu file). |
| proxy | Proxy yêu cầu FTP qua HTTP proxy. Chỉ áp dụng đọc file. Ví dụ: tcp://squid.example.com:8000. |
Ví dụ cho phép fopen() ghi đè file trên FTP:
Ví dụ
<?php $ftp_path = 'ftp://username:password@example.com/example.txt'; $stream_options = array('ftp' => array('overwrite' => true)); $stream_context = stream_context_create($stream_options); $fh = fopen($ftp_path, 'w', 0, $stream_context); fputs($fh, 'Hello World'); fclose($fh); ?>