Forum Moderators: coopster

Message Too Old, No Replies

php text file

any option?

         

c0nsur

9:34 pm on Aug 19, 2003 (gmt 0)

10+ Year Member



is it possible to put a text file on a computer

i know php is server side
and a client is cleint side but maybe theres a way :)

bcolflesh

9:38 pm on Aug 19, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



If your script has permission to write to their server - sure. Probably not what you are asking to do though...

c0nsur

9:40 pm on Aug 19, 2003 (gmt 0)

10+ Year Member



nah its just a kind of save as with some interesting values in it for the customers

panic

10:53 pm on Aug 19, 2003 (gmt 0)

10+ Year Member




$filename = "yourtextfile.txt";

$data = "This is the data you want to put into the text file.";

$fp = fopen("$filename","w");

fputs($fp,$data);

Have fun.

-panic

jonknee

12:41 am on Aug 20, 2003 (gmt 0)

10+ Year Member



That code snippet won't work... That's server side. :P

coopster

12:25 pm on Aug 20, 2003 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



I could be wrong here, but you seem to be describing cookies...or do you need more than that? If so, you'll want to have them log in, save their information on the server side, and next time they return they would log in again and you would retrieve their information to display once again.

Timotheos

4:17 pm on Aug 20, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



There's a way to force the browser to download the page you've created by sending the right headers. Here's an example of how I can have someone download an excel file. The rest of the php simply creates a grid of values.

header("Content-type: application/vnd.ms-excel");
header("Content-disposition: csv" . date("Y-m-d") . ".xls");

This method can be used for many different file types. The basics for a text file would be something like

header("Content-type: application/octetstream");
header("Content-Disposition: filename=$file");

panic

4:30 pm on Aug 20, 2003 (gmt 0)

10+ Year Member



I could be wrong here, but you seem to be describing cookies...

Got that right, buddy. I thought you meant you want that text file server-side... I don't see why you'd want it client side.

-panic

c0nsur

5:09 pm on Aug 20, 2003 (gmt 0)

10+ Year Member



header("Content-type: application/octetstream");
header("Content-Disposition: filename=$file");

sounds really good
anyone has a complete and simple example for this thing?
:)