- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- MS Excel
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
PHP FTP context options
Introduction
Context options for http:// and https:// transports are listed below −
overwrite | Allow overwriting of already existing files on remote server while uploading only. |
resume_pos | File offset at which to begin transfer. Applies for downloading only.Defaults to 0 (Beginning of File). |
proxy | Proxy FTP request via http proxy server. Applies to file read operations only. Ex −tcp://squid.example.com:8000. |
This example shows how to allow fopen() to overwrite a file on an FTP site.
Example
<?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); ?>
Advertisements