Ramui forum script
Home :: Ramui forum script :: Developer discussion board :: Link to download a text file
Select Style:
User:
User:
Password:
Keep me login in this computer

Link to download a text file

I want to provide a link to download a text file. Part of that text file will be variable, user IP address. Does anyone know how to do this?
Posted by: willy;   Post:3;   Comments:2;  Date of Join: Dec 17, 2008, 15:25
Post date: Dec 17, 2008, 15:32
New topicReplyContactReport

Re: Link to download a text file

What exactly you’re looking for? Do you want to create a text file at run time and open it on the browser window?

-----------------------------------------------------------
Web hosting directory

Posted by: admin;   Post:34;   Comments:116;  Date of Join: Nov 05, 2008, 08:04
Post date: Dec 18, 2008, 02:16
ContactReport

Re: Link to download a text file

I need a forced download script of a text file whose content will be written at runtime.
Posted by: willy;   Post:3;   Comments:2;  Date of Join: Dec 17, 2008, 15:25
Post date: Dec 20, 2008, 15:09
ContactReport

Re: Link to download a text file

Code
<?php
function download_text($text,$filename)
{
    header("Content-type: application/text");
    header("Content-Disposition: attachment; filename=$filename");
    echo $text;
}
$msg="Some text".$_SERVER['REMOTE_ADDR']."another text";
$filename="download.txt";
download_text($msg,$filename);
?>
Save this code at a separate php file say "download.php". Now just provide a link to open that file.

-----------------------------------------------------------
Web hosting directory

Posted by: admin;   Post:34;   Comments:116;  Date of Join: Nov 05, 2008, 08:04
Post date: Dec 20, 2008, 15:42
ContactReport