Printable Version of Topic

Click here to view this topic in its original format

HTMLHelp Forums _ Server-side Scripting _ write file on server side

Posted by: DS92 Feb 3 2019, 11:12 AM

Goodmorning, I would like that input on html page are automatically saved in a txt file on server. I found that it could be reach with javascript and php scripts but I couldn't understand how.
The next step could be modify the file and read it in order to find if the client input are already in the file.
Could someone help me? thank you very much
Best Regards

Posted by: Darin McGrew Feb 3 2019, 11:41 AM

What server-side programming languages can you use? PHP? Python? Perl?

Posted by: Christian J Feb 3 2019, 02:05 PM

Good evening!

QUOTE(DS92 @ Feb 3 2019, 05:12 PM) *

input on html page are automatically saved

Do you mean after the user submits a form, or automatically while the user types?


Posted by: DS92 Feb 4 2019, 04:48 AM

Thank you very much, I would like that when I submit start a javascript which call a php o nodejs code to save user inputs in file txt or change txt file. I available to write server side in python php or nodejs codes. I don't know Perl code

Posted by: Christian J Feb 4 2019, 11:03 AM

QUOTE(DS92 @ Feb 4 2019, 10:48 AM) *

Thank you very much, I would like that when I submit start a javascript which call a php o nodejs code to save user inputs in file txt or change txt file.

You don't need javascript for that, just use the server-side script's URL in the form's ACTION attribute and the script will run automatically when the form is submitted. But if you must use javascript, it can be done with an Ajax request.

QUOTE
I available to write server side in python php or nodejs codes. I don't know Perl code

Wth PHP this one can be used: http://php.net/manual/en/function.file-put-contents.php


Posted by: DS92 Feb 5 2019, 09:43 AM

Thank you very much for your answer. I tried with AJAX method but always appears in visual studio code the following error:
Failed to load resource: the server responded with a status of 405 (Method Not Allowed) [http://127.0.0.1:5500/test.php];

could some one help me to solve also this problem? I read about web.config file but I don't know if it could be usefull and how to create and call it from html page in visual studio code.
Thank you very much

Posted by: Darin McGrew Feb 6 2019, 02:39 PM

When I've seen 405 Method Not Allowed, it has been either because a form was trying to POST to a static web page that could only be retrieved via GET, or because a link was trying to access a form-handling URL via GET when the server-side program would accept only POST.

Posted by: CharlesEF Feb 6 2019, 04:25 PM

I've seen the '405 Method Not Allowed' error when the page is .htm or .html and it tries to make a POST ajax call. I use IIS web server so I've run into it. I think IIS only allows GET ajax calls (unless you reconfigure the web server).

Posted by: Daniel Feenberg Feb 19 2019, 11:32 AM

Does anyone know where the format of the input to the server script is detailed? That is, the server script reads from the standard input and the sections are delimited by headers such as:
------------0xKhTmLbOuNdArY
Content-Disposition: form-data; name="userfile"; filename="test.txt"
Content-Type: text/plain

but I can't find where this is documented. It doesn't seem to be in RFC3875.

Daniel Feenberg

Powered by Invision Power Board (http://www.invisionboard.com)
© Invision Power Services (http://www.invisionpower.com)