|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #2773 overwriting file with ftp problem
Submitted: 1999-11-19 23:20 UTC Modified: 2002-06-16 09:00 UTC
From: tdouglas at home dot com Assigned:
Status: Not a bug Package: Misbehaving function
PHP Version: 3.0.12 OS: linux
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
Solve the problem:
7 + 2 = ?
Subscribe to this entry?

 [1999-11-19 23:20 UTC] tdouglas at home dot com
$fname = "ftp://user:passwd@myipaddress/../../../../www/htdocs/chemistry/";
$fname .= $name;
$fname .= "_post.html";
$file = fopen($fname, "a"); // ERROR HERE

The problem seems to be that when I run this I will get a warning that the file alread exists and it fails to open the file. In the docs it says that it will append the file if it already exists and NOT return a bad file pointer. This also fails if the mode is 'w'. However, it does work if the file doesn't exist. But it won't overwrite a file.

I didn't see any documentation that mentions that this will happen if this turns out not to be a bug...

I have php4 but I know someone else that got the same problem with a php3 version.

if (!$file)
	echo "<BR>Error opening file.";

fputs($file,"<BR>" . "$comment" . "<HR>");
echo "$fname" . " has added a comment from " . "$name" . " which says, " . "$comment";



Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2000-03-02 13:01 UTC] joey at cvs dot php dot net
So is this a PHP3 or PHP4 bug? It was created as 3.0.12, but
you seem to be saying that it is in version 4? If you are seeing
this in 4, plz update to either a newer beta, or a snapshot.
 [2000-07-25 12:55 UTC]
regarding mode "w":
ftp fopen wrapper does not allow
overwriting existing files even
if the ftp server would give you
permission to do so

regarding mode "a":
i'm not even sure FTP protocol
supports this  ... ???
 [2002-06-16 09:00 UTC]
Thank you for taking the time to report a problem with PHP.
Unfortunately, PHP 3 is no longer supported. Please download
the latest version of PHP 4 from

If you are able to reproduce the bug with one of the latest
versions of PHP, please change the PHP version on this bug report
to the version you tested and change the status back to "Open".
Again, thank you for your continued support of PHP.
PHP Copyright © 2001-2019 The PHP Group
All rights reserved.
Last updated: Tue Oct 22 11:01:29 2019 UTC