How do I create text file from web...

User 46144 Photo


Registered User
12 posts

Hi,
I would like to have my web page create a text file containing the user input of a form.

The input in the form should be formatted with a newline after every single information, instead of being one single string of text.

Obviously I have tried to look up a solution on the web first, and there are a few good examples, eg stack overflow, but either haven't made the examples work, or the solution will not support all/common browsers.

So I am a bit stuck here.

Since I earlier had good and thorough advice in here, I thought asking you guys could help me out.

Thank you very much!

Kind regards,
Steen
User 122279 Photo


Senior Advisor
14,447 posts

It can be done by php. I can't explain exactly how, so just wait until Eric discovers this thread ;)
Ha en riktig god dag!
Inger, Norway

My work in progress:
Components for Site Designer and the HTML Editor: https://mock-up.coffeecup.com


User 187934 Photo


Senior Advisor
20,181 posts

How and when do you want the text file to be generated? There may be a few ways to do this depending on your end need and your abilities.
I can't hear what I'm looking at.
It's easy to overlook something you're not looking for.

This is a site I built for my work.(RSD)
http://esmansgreenhouse.com
This is a site I built for use in my job.(HTML Editor)
https://pestlogbook.com
This is my personal site used for testing and as an easy way to share photos.(RLM imported to RSD)
https://ericrohloff.com
User 46144 Photo


Registered User
12 posts

Hi Eric,

Well, Inger set expectations miles high! :D

When a user fills in a form on my website and presses submit-button, I would like my page (JS, PHP, whatever) to generate that file and then present the user with a link to download that file.

Due to your question, I have thought about where the file should be created, and if created on my site, then either my webhotel/site soon will be overcrowded with text-files, or simoultaneous users will fight to get their own version of the text-file (I guess, I'm on deep water here!).

Preferably I would like a text file created on the users pc, and then by offering a link to that file, letting the user decide what to do with it (save, open/edit/reformat, print, ..., whatever!)

Does this make sense, or am I babbeling?

Kind regards,
Steen
User 122279 Photo


Senior Advisor
14,447 posts

I thought you wanted the info that is submitted to remain on a site, not just displayed to the customer. For that you may need Eric's help.

But if it is only for the customer to see, that can be done without any extra fiddling directly in the Form builder.
You have different options in the settings: Send a confirmation mail, show the results on the screen right after posting, or send the customer to a different page, also with the form results displayed. If you like, you can test it on my contact page on the site I have in my signature, you will get the two first alternatives. If you have a form where the customer can upload a file, it clearly won't be necessary for the same customer to download that file, it will already be on their machine.
Ha en riktig god dag!
Inger, Norway

My work in progress:
Components for Site Designer and the HTML Editor: https://mock-up.coffeecup.com


User 46144 Photo


Registered User
12 posts

Hi Inger,

Nice thought, and would seem to be the easy way around it.

But!

I'd like to format the content of the file, including some information, not including other, and setting it up in a - to the user - useful way.

So I'd still need to create a text-file for the user to download after he or she submits the form.

I saw a nice example on the net doing just that using JavaScript. Though the code was corrupted, and once corrected, I found that the solution - for whatever reason - did not work on both Chrome and IE, so I dropped that.
Seems to remember that it had something to do with checking if the file was existing ahead, and if not, initiate it.

My soulution wold have to work regardless of which browser the user will be using, so ...

I need to create a text file with string concatenations, LF/NL etc., and not just the raw form data.

Kind regards,
Steen
User 187934 Photo


Senior Advisor
20,181 posts

If the person is filling out the form why not use the confirmation to send the info to them since it's already setup. This way your not doing unnecessary coding. You can print and do "save as" with webpages.
I can't hear what I'm looking at.
It's easy to overlook something you're not looking for.

This is a site I built for my work.(RSD)
http://esmansgreenhouse.com
This is a site I built for use in my job.(HTML Editor)
https://pestlogbook.com
This is my personal site used for testing and as an easy way to share photos.(RLM imported to RSD)
https://ericrohloff.com

Have something to add? We’d love to hear it!
You must have an account to participate. Please Sign In Here, then join the conversation.