String to text file

driveflexfuel

New Member
Messages
159
Reaction score
0
Points
0
I am looking for a script that will allow me to turn a string to a text file for the user to download without having to save the file to my server.

If this is possible can anyone help me with a sample. I have looked all over google but it just shows me how to save to a text file on the server.

Thanks for any help
 

driveflexfuel

New Member
Messages
159
Reaction score
0
Points
0
I managed to figure this one out on my own. This is the code im currently using. If there is a better way I would appreciate the advice.

Code:
header('Cache-Control: private');
header('Pragma: private');
header("Content-Disposition: attachment; filename=\"file.txt\"");
header("Content-Type: application/octet-stream;");
echo $_POST['content'];
 

misson

Community Paragon
Community Support
Messages
2,572
Reaction score
72
Points
48
That's basically the best way. With the Content-Disposition header, you should be able to set the proper MIME type for the content. If the string is text, set the Content-type to "text/plain".
 
Top