0
I am having trouble saving my data to a . txt on my FTP server.
Locally managed quiet. Below is the code I am using locally:
$arquivo = 'msg.txt';
$criar = fopen($arquivo, "a+");
$conteudo = "$nome; $idade; $sexo; $telefone;".PHP_EOL ;
$escrever = fwrite($criar, $conteudo);
But I need to write to a . txt that is on my FTP server.
I saw that indicating the path of the file with HTTP will not work, but I did not find a solution how to link to the FTP server.
The code I’m using to try to communicate online with . txt is the same, only changes one line, which is the file path.
$arquivo = 'www.domain.net/pasta/arquivo.txt';
The following error message is displayed (with HTTP):
failed to open stream: HTTP wrapper does not support writeable connections
I didn’t understand it very well. I guess I didn’t know how to define what I need. Come on! Need to save data from a web form to a file . txt on my FTP server. For example, on the page of my site when the user sends the information, the information should be entered in . txt so that later I can import to Excel. I don’t own BD, so the use of . txt, and because it is easy to manipulate this data in Excel. From what I understand, the example you gave me is to upload right? Actually I need to write in txt file when user click to send :/
– Guilherme Luis
But in the second example you do this. Generates the file in the hosting and then sends. Unless you do not know how to make a form.
– RpgBoss
I got it, thank you very much !
– Guilherme Luis
I forgot to present something interesting, but it is optional, if you want to delete the file generated in the hosting after already having the copy in FTP use unlink() - I edited the answer for you to analyze
– RpgBoss