Apr 10, 2008, 4:51 PM
Post #1 of 4
Output cgi as .txt extension
I searched the FAQ and general board, but can't find the answer to this.
I have written a script that allows users to upload a log file (which I store to a mysql database as plain text). I then use another script that removes some predefined lines (by way of a foreach loop that replaces lines by regex match. Not efficient, but works).
The final aspect is that if the "trimmed" log is still larger than, say 2000 lines, I don't want it to display in a browser but rather give the users a link to save the file. I have achieved this, but my script merely checks the output after regex processing and if over 2000 lines, it runs the script again but with a simple "Content-type: text/plain" header. The filename the users get in the save-as dialog is myscriptname.cgi.
I would like for them to get processedfile.txt. I don't want to save the text on the server, as that will get very large as users may run the script with different options.
Any suggestions (or can I make this more clear, in case I've muddled my explanation)?