บทนำ
Context options สำหรับ transports ftp:// และ ftps:// มีดังนี้
| overwrite | อนุญาตเขียนทับไฟล์ที่มีอยู่แล้วบน remote server ขณะ upload เท่านั้น |
| resume_pos | File offset ที่เริ่ม transfer ใช้สำหรับ download เท่านั้น ค่าเริ่มต้น 0 (Beginning of File) |
| proxy | Proxy FTP request ผ่าน http proxy server ใช้สำหรับ file read operations เท่านั้น Ex - tcp://squid.example.com:8000 |
ตัวอย่างนี้แสดงวิธีอนุญาตให้ fopen() เขียนทับไฟล์บน FTP site
ตัวอย่าง
<?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); ?>