PHP FTP 上下文选项
引言
http:// 和 https:// 传输的上下文选项如下 −
| 覆盖 | 在仅上传时,允许覆盖远程服务器上已有的文件。 |
| 恢复位置 | 传输开始时的文件偏移量。仅适用于下载。默认为 0(文件开头)。 |
| 代理 | 通过 http 代理服务器代理 FTP 请求。仅适用于文件读取操作。例如 tcp://squid.example.com:8000。 |
本示例演示如何允许fopen()覆盖 FTP 站点上的文件。
示例
<?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);
?>
广告
数据结构
网络
关系型数据库管理系统
操作系统
Java
iOS
HTML
CSS
Android
Python
C 语言编程
C++
C#
MongoDB
MySQL
Javascript
PHP