NetTalk Central

Author Topic: Example 72 with a Text file  (Read 3082 times)

Richard I

  • Sr. Member
  • ****
  • Posts: 381
    • View Profile
    • Email
Example 72 with a Text file
« on: December 13, 2019, 07:40:46 PM »
Hi,
Im using Example 72 and want to download a Text file instead of a CSV as in the example...
On clicking  the file download, the contents of the text file are displaying in a new browser tab

close(dosfile) does not solve

How can I bring the text file down without opening it ?
Thanks
Richard
NT 11.27
« Last Edit: December 14, 2019, 12:30:53 AM by Richard I »

Jane

  • Sr. Member
  • ****
  • Posts: 349
  • Expert on nothing with opinions on everything.
    • View Profile
    • Email
Re: Example 72 with a Text file
« Reply #1 on: December 14, 2019, 09:34:12 AM »
Try example 40 (FileDownload) instead.

Richard I

  • Sr. Member
  • ****
  • Posts: 381
    • View Profile
    • Email
Re: Example 72 with a Text file
« Reply #2 on: December 14, 2019, 12:56:38 PM »
Thank you Jane,
It seems to me that example 72 integrates better and provides the option of file type.

I need to know however , why the CSV file comes down as a file but the text file seemingly doesn't,  displaying in the Chrome browser opened, in a new tab

Yes, FileDownload ( example 40) is an option...but I would rather not
I have found it works OK provided the cache option is unticked in the web Server

Appreciate your help.
Regards,
Richard

Richard I

  • Sr. Member
  • ****
  • Posts: 381
    • View Profile
    • Email
Re: Example 72 with a Text file
« Reply #3 on: December 14, 2019, 05:08:43 PM »
Further to-
If the link "Click here to download file " is right clicked the option to" save link as " will download the TEXT  file to the location nominated.
Thats acceptable
Richard
« Last Edit: December 14, 2019, 08:17:42 PM by Richard I »

Jane

  • Sr. Member
  • ****
  • Posts: 349
  • Expert on nothing with opinions on everything.
    • View Profile
    • Email
Re: Example 72 with a Text file
« Reply #4 on: December 14, 2019, 09:13:48 PM »
Sure, right-click works.

But example 40 works with a regular click (in case you have trouble training your users).

Richard I

  • Sr. Member
  • ****
  • Posts: 381
    • View Profile
    • Email
Re: Example 72 with a Text file
« Reply #5 on: December 14, 2019, 09:46:57 PM »
Yes - time will tell
I did have problems earlier, with FileDownload(40) in that it was downloading a cached file rather than the latest,
and at the time I didnt fancy having to tell users to clear the browser cache.

I believe( think) that having the cache option Unticked has sorted it, however....I like the format of the 72 example.

Incidently, I found your posting on the  c:\windows\system32\drivers\etc\HOSTS  , specifically getting localhost and 127.0.0.1 to work,  very interesting and useful... it just shows you, help given  on this forum, stretches far and wide.
Much obliged
Cheers
Richard

Jane

  • Sr. Member
  • ****
  • Posts: 349
  • Expert on nothing with opinions on everything.
    • View Profile
    • Email
Re: Example 72 with a Text file
« Reply #6 on: December 15, 2019, 01:59:17 PM »
I haven't done it, Richard.  But I'd think you could combine the two.

Create the report or file as in example 72.

But in the Value::FileProgress routine, instead of creating a URL as that example does, do something like example 40 (p_web.HeaderDetails.ContentDisposition = 'attachment; filename="   ... etc.)

I think the "attachment" in the header is what's telling the browser not to try to open the file directly, and is apparently the behavior you're looking for.

JAT....

Jane