1. No Profile Picture
    Devshed Newbie (0 - 499 posts)
    I am looking for a quick and simple solution for following task:

    On all (meaning: many) generated HTML-pages I intend to offer a DOWNLOAD of a textfile, according to the text of the HTML-page.

    The textfiles (ASCII, *.txt or *.pdf - depending on what is easier to program) should contain: the whole text-contents (also in table-layout) of the HTML-pages (except images, links etc.).

    Techncal Info: The HTML-pages have been programmed with PHP3 and JavaScript (many interrogations) and read data from a database with MYSQL.

    So far I only would be able to realize this either doing a lot of programming (i.e. to define the page size, row witdth, change special characters, transfer tables 1:1 ...) or I would have to ask the surfer to use the browser features to save the HTML-page as a textfile (but last solution shall not be used although the result is perfect).

    I hope there is a function or a program (freeware) which will generate the textfiles automaticillay during the process of programming the website at a time I can choose myself by just placing 1 comand into the program.

    Who has got a good idea? I would be very happy to hear about some trick and tips.


    Suche schnelle, einfache Lösung für folgende Aufgabe:

    Auf allen (d.h. sehr vielen) generierten HTML-Seiten möchte ich jeweils einen entsprechenden DOWNLOAD von einem Textfile anbieten.

    Die Textfiles (ASCII, *.txt oder *.pdf - je nachdem, was einfacher zu programmieren ist) sollen beinhalten: den gesamten Text-Inhalt (auch in Tabellen-Form) der zu sehenden HTML-Seite (außer Bilder, Links etc.).

    Technische Info: Die HTML-Seiten sind u.a. mit PHP3 und Javascript programmiert (viele Abfragen) und lesen mit MYSQL Daten aus der Datenbank aus.

    Bisher würde ich dieses nur durch aufwendige Programmierung (u. a. definieren der Seitengröße, Zeilenbreite , Umwandlung sämtlicher Sonderzeichen, Tabellen 1:1 umsetzen etc.) realisieren können oder den Surfer bitten, über den Browser die Datei als Textfile zu speichern (letzteres soll aber nicht gemacht werden, obwohl das Ergebnis hervorragend ist).

    Ich hoffe, es gibt irgendeine Funktion oder ein Programm (Freeware), welches die Textfiles im Zuge der Programmierung der WebSite zu einem von mir gewählten Zeitpunkt automatisch generiert, indem ich z.B. einfach nur 1 Befehl in das Programm hierfür einbinde.

    Wer hat eine gute Idee? Über Tips und Trick würde ich mich sehr freuen.

  2. #2
  3. Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2003
    San Angelo, Texas (USA)
    Rep Power
    This one can be difficult, but not impossible. I will give you an example to play with and I will tell you how it works - I have a feeling you will be able to figure it out easily.

    What to do:
    Create a file and put this into it:
    PHP Code:

    ('Content-Type: application/octetstream'); 
    header('Content-Disposition: attachment; filename=test.txt');
    header('Pragma: public');

    "Hello, world!\r\n";
    "I know how to MAKE people download my text!";

    Next, link to this script from another HTML page using an anchor, button, or whatever. When you click the link/button, the download dialong will pop up.

    How it works:
    You have to tell the browser to do something other than display the text. The above works for IE and Opera, and for Netscape/Mozilla change application/octetstream to application/octet-stream. Also, you can pass GET or POST values to this script (in case it wasn't entirely obvious).

    Here's the catch: this file cannot be an include, otherwise you risk outputting all your HTML source code to the text file. Simply link to this script and your download box will appear, yet the page will stay at it's current location.

    Anyway, that's the basics - but I can explain in greater detail if you need the help. Good luck.

Similar Threads

  1. call up cgi in html with javascript
    By wolsch in forum JavaScript Development
    Replies: 1
    Last Post: February 16th, 2004, 03:45 PM
  2. calling a variable in the html with javascript
    By grungefade in forum JavaScript Development
    Replies: 4
    Last Post: February 10th, 2004, 04:34 PM
  3. using xml data in an html form via javascript
    By jason2584 in forum JavaScript Development
    Replies: 2
    Last Post: January 28th, 2004, 03:42 PM
  4. How to get client email??Help plz
    By Gecko22 in forum ASP Programming
    Replies: 12
    Last Post: January 22nd, 2004, 01:40 PM
  5. not returning records when it should
    By aliaga61 in forum ASP Programming
    Replies: 3
    Last Post: January 16th, 2004, 10:57 AM

IMN logo majestic logo threadwatch logo seochat tools logo