|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2001-07-10 06:07 UTC] koenig at internet24 dot de
Configure './configure' '--with-apxs=/usr/local/apache/bin/apxs'
Command '--with-mysql' '--with-pgsql' '--with-zlib' '--enable-ftp'
'--with-gd' '--with-jpeg-dir=/usr/local/lib'
'--enable-versioning' '--enable-track-vars=yes'
'--enable-url-includes' '--enable-sysvshm'
'--enable-syscsem' '--with-gettext'
<?php
$file = "user:secret@somewhere.org/path/file.txt";
if (!($fp = fopen($file, "r+"))) {
echo "error: can't open file<br>";
exit;
}
fputs($fp, "test number one...");
fputs($fp, "test number two...");
fputs($fp, "etc...");
fclose($fp);
?>
-------------------------------
The problem is, that nothing is written in the file even though fopen,fputs and
fclose do not return an error.
If you use fopen($file, "a+") the strings are written to file. But now
the problem is, that fopen tries to create that file even if it already exists.
Ciao,
Tobias
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Tue Nov 18 20:00:01 2025 UTC |
The following patch will issue a warning for trying to open a ftp file in anything other than read/write, - as no other methods are supported by fopen(ftp) as far as producing errors on 'writing to an ftp file opened read only' - this is more complex as there is no indicators on the socket to tell wheter it was opened read or write, (internally the socket is opened rw as the actual connection is a 2 way communication) Index: ftp_fopen_wrapper.c =================================================================== RCS file: /repository/php4/ext/standard/ftp_fopen_wrapper.c,v retrieving revision 1.11 diff -u -r1.11 ftp_fopen_wrapper.c --- ftp_fopen_wrapper.c 9 Sep 2001 13:29:18 -0000 1.11 +++ ftp_fopen_wrapper.c 17 Dec 2001 10:24:06 -0000 @@ -101,6 +101,14 @@ *issock = BAD_URL; return NULL; } + if (strcmp(mode, "r") && strcmp(mode, "w")) { + php_error(E_WARNING, "Invalid mode : ftp can only access files in (r)ead or (w)rite mode"); + php_url_free(resource); + *issock = BAD_URL; + return NULL; + } + + /* use port 21 if one wasn't specified */ if (resource->port == 0) resource->port = 21;