php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #7121 fopen() doesn't owerwrite files opened via a FTP connection
Submitted: 2000-10-10 11:41 UTC Modified: 2003-04-21 23:15 UTC
Votes:1
Avg. Score:5.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:0 (0.0%)
Same OS:1 (100.0%)
From: mums at mums dot cx Assigned:
Status: Closed Package: Feature/Change Request
PHP Version: 4.0.2 OS: Linux
Private report: No CVE-ID: None
 [2000-10-10 11:41 UTC] mums at mums dot cx
I think it would be useful if one could owerwrite files also in FTP file mode.
For an example, this won't work if the file already exists:

<?php
$fp = fopen('ftp://test:test@localhost/home/test/testfil.bin', 'w+');
fwrite($fp, 'test');
fclose($fp);
?>

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2003-04-21 23:15 UTC] pollita@php.net
As of PHP 5.0 this feature will be available using the ftp context option overwrite set to any non-zero value.

<?php
  $context = stream_context_create();
  stream_context_set_option($context, 'ftp', 'overwrite', 1);

  $fp = fopen('ftp://user:host@remoteserver.com/path/to/file', 'w', false, $context);


?>

 
PHP Copyright © 2001-2026 The PHP Group
All rights reserved.
Last updated: Sun Jun 14 20:00:01 2026 UTC