Newsgroup: it.comp.www.php
Titolo: problemi di sovrascrittura file

Ho la necessità di poter scrivere e sovrascrivere o aggiungere testo in un
file tramite un semplice form!
Il codice sotto riportato crea e scrive un file e funziona, ma una volta
creato non lo sovrascrive mi dice
che il file esiste.... e quindi si blocca ....
<?
$fp = fopen("$nomefile", "w") or die ("Impossibile aprire il file $file");
fwrite($fp, $test);
fclose($fp);
?>
Qualcuno potrebbe darmi una dritta per capire se la funzione fopen() oltre a
creare un file, una volta creato,  lo  stesso file possa essere aperto in
modalità scrittura per essere sovrascritto dalla funzione fwrite() o
aggiungere una nuova stringa allo stesso file con la funzione fputs(),
insomma per farla corta questo file una volta creato con il codice su
riportato può essere o no sovrascritto? Se è si, perchè a me non
funziona......
NB sistema operativo Linux
Grazie per l'aiuto

Ti allego la spiegazione che č presente sul manuale di PHP in 
www.php.net
.
fopen(PHP 3, PHP 4 )
Opens file or URL
int fopen (string filename, string mode [, int use_include_path])
If filename begins with "http://" (not case sensitive), an HTTP 1.0
connection is opened to the specified server and a
file pointer is returned to the beginning of the text of the response. A '
Host:' header is sent with the request in order to
handle name-based virtual hosts.
Does not handle HTTP redirects, so you must include trailing slashes on
directories.
If filename begins with "ftp://" (not case sensitive), an ftp connection to
the specified server is opened and a pointer
to the requested file is returned. If the server does not support passive
mode ftp, this will fail. You can open files for
either reading or writing via ftp (but not both simultaneously).
If filename is one of "php://stdin", "php://stdout", or "php://stderr", the
corresponding stdio stream will be opened.
(This was introduced in PHP 3.0.13; in earlier versions, a filename such as
"/dev/stdin" or "/dev/fd/0" must be used to
access the stdio streams.)
If filename begins with anything else, the file will be opened from the
filesystem, and a file pointer to the file
opened is returned.
If the open fails, the function returns false.
mode may be any of the following:
. 'r' - Open for reading only; place the file pointer at the beginning of
the file.
. 'r+' - Open for reading and writing; place the file pointer at the
beginning of the file.
. 'w' - Open for writing only; place the file pointer at the beginning of
the file and truncate the file to zero length. If
the file does not exist, attempt to create it.
. 'w+' - Open for reading and writing; place the file pointer at the
beginning of the file and truncate the file to zero
length. If the file does not exist, attempt to create it.
. 'a' - Open for writing only; place the file pointer at the end of the
file. If the file does not exist, attempt to create it.
. 'a+' - Open for reading and writing; place the file pointer at the end of
the file. If the file does not exist, attempt to
create it.
The mode may contain the letter 'b'. This is useful only on systems which
differentiate between binary and text files
(i.e., it's useless on Unix). If not needed, this will be ignored.
You can use the optional third parameter and set it to "1", if you want to
search for the file in the include_path, too.
Example 1. Fopen() example
$fp = fopen ("/home/rasmus/file.txt", "r");
$fp = fopen ("/home/rasmus/file.gif", "wb");
$fp = fopen ("
http://www.php.net/
", "r");
$fp = fopen ("
ftp://user:pass...@example.com/
", "w");
If you are experiencing problems with reading and writing to files and you'
re using the server module version of PHP,
remember to make sure that the files and directories you're using are
accessible to the server process.
On the Windows platform, be careful to escape any backslashes used in the
path to the file, or use forward slashes.
$fp = fopen ("c:\\data\\info.txt", "r");
Ciao, Nicola
----------------------------------------------------------------------------
vieni su
www.pignatelli.com
Risorse Web per principianti e non
----------------------------------------------------------------------------

 Ti allego la spiegazione che è presente sul manuale di PHP in 
www.php.net
.
