php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #14095 fopen/fwrite does not create file via "ftp://"
Submitted: 2001-11-17 17:16 UTC Modified: 2002-01-02 09:44 UTC
From: jason at audiorapture dot com Assigned:
Status: Closed Package: FTP related
PHP Version: 4.0.6 OS: Windows NT4 SP6a
Private report: No CVE-ID: None
 [2001-11-17 17:16 UTC] jason at audiorapture dot com
PHP as CGI on NT4SP6a/IIS4.

To update a file on the server, I read the old contents into an array, populate a string with modified content, delete the old file, and use fopen/fwrite to write a new one.
This worked great on FreeBSD/Apache, now on NT4/IIS4 the new file is not written.

There are *no* error messages, but the file is not there.

Really messed up is the fact that the file is written successfully when I specify the previous FreeBSD/Apache host in $FTPSite...

The following variables are defined before the code below runs:
$newcontents
$FTPUser
$FTPPass (contains special characters, e.g. "urb@n")
$FTPSite ("host.domain.tl")
$FTPDoc  ("/path/filename")

[Curiously, I cannot use "localhost" or an IP address as $FTPSite...("unable to find ftpbuf 0" on ftp_login and ftp_delete as well as "php_hostconnect: connect failed" on fopen)]

// delete previous file via ftp
$ftp = ftp_connect($FTPSite);
ftp_login($ftp, $FTPUser, $FTPPass);
ftp_delete($ftp, $FTPDoc);
ftp_quit($ftp);

// get file handler
$FTPOpen="ftp://" . rawurlencode($FTPUser) . ":" . rawurlencode($FTPPass) . "@" . $FTPSite . $FTPDoc;
//echo $FTPOpen . "<BR>";
$NewTopTen = fopen($FTPOpen,"w");
echo $NewTopTen;
// write new content to file
fwrite($NewTopTen, $newcontents);

//close file handle
fclose($NewTopTen);

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2001-11-17 17:32 UTC] mfischer@php.net
Can you please test with a more recent version (e.g. from php4win.de) ?

 [2001-11-17 17:52 UTC] jason at audiorapture dot com
Unfortunately I do not have authority over that server. But I will try to either set up a test box (don't have NT4 available right now) or convince the admin to upgrade - so is there a known issue?
 [2002-01-02 09:44 UTC] mfischer@php.net
No Feedback, closing.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Dec 26 11:01:30 2024 UTC