So with your second method, I do not need to create an empty text file on my server right?
For some reason I can't make it work. I think it's because php files don't have the authorization to write on my server or something like that.
I will check that with the I.T guy of my lab and try again ^^
Thanks anyway !
Just out of curiosity. What part of the php code deals with the creation of a new file if there is no matching file name on the server ? Is it just how "fopen" works ? Then why do you need to create in advance a text.txt file with the first method ?
Its the "w" parameter
$myfile = fopen("text.txt", "w") or die("Unable to open file!");
"r" read: Open file for input operations. The file must exist.
"w" write: Create an empty file for output operations. If a file with the same name already exists, its contents are discarded and the file is treated as a new empty file.
"a" append: Open file for output at the end of a file. Output operations always write data at the end of the file, expanding it. Repositioning operations (fseek, fsetpos, rewind) are ignored. The file is created if it does not exist.
"r+" read/update: Open a file for update (both for input and output). The file must exist.
"w+" write/update: Create an empty file and open it for update (both for input and output). If a file with the same name already exists its contents are discarded and the file is treated as a new empty file.
"a+" append/update: Open a file for update (both for input and output) with all output operations writing data at the end of the file. Repositioning operations (fseek, fsetpos, rewind) affects the next input operations, but output operations move the position back to the end of file. The file is created if it does not exist.
So should write a new file to the server, if it does not exist.