GIDForums  

Go Back   GIDForums > Computer Programming Forums > MySQL / PHP Forum
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

 
 
Thread Tools Search this Thread Rate Thread
  #1  
Old 26-Aug-2007, 23:25
venkib097 venkib097 is offline
New Member
 
Join Date: Jul 2007
Posts: 7
venkib097 is on a distinguished road

How can I download (open) .txt file?


how can i open (download) .txt file , i.e located in my local system by using php coding.when i click some link,it automatically open the .txt file(located on C:/folder/test.txt). please anybody help me.how can i do that.
  #2  
Old 19-Oct-2007, 21:13
filth filth is offline
New Member
 
Join Date: Oct 2007
Posts: 5
filth is on a distinguished road

Re: How can i download (open) .txt file?


quite simple you use a function such as http://uk3.php.net/fopen
  #3  
Old 10-Nov-2007, 20:03
MonkOfox MonkOfox is offline
New Member
 
Join Date: Nov 2007
Posts: 21
MonkOfox is on a distinguished road

Re: How can i download (open) .txt file?


use fopen()

PHP Code:

<?php

$fd = fopen("file path","METHOD"); 
// where METHOD can be many things:
       // 'r' for reading
       // 'w' for writing
       // 'a+' for appending 
       // etc..

// then do a loop to get all the text in that file.

$i = 0;

while(!feof($fd))  // basicaly means while not(!) found(f) end(e) of(o) file(f) 
// then the file descriptor.
{ $buffer = fgets($fd,256); // get 256 character until it reaches eof or '\n' 
// or '\r' 
   echo $buffer; // prints that current line to the page
}
// you could also print this to another file 


?>


you can use this to get started, then google more advanced stuff you want to do.

Hope this helps.

MonkO
Last edited by admin : 10-Nov-2007 at 22:03. Reason: Please insert your example PHP codes between [PHP] and [/PHP] tags
  #4  
Old 11-Nov-2007, 05:27
filth filth is offline
New Member
 
Join Date: Oct 2007
Posts: 5
filth is on a distinguished road

Re: How can I download (open) .txt file?


oops just noticed i didnt seem to finish my post, i did mean to put look at fopen at http://uk3.php.net/fopen
 
 

Recent GIDBlog2nd Week of IA Training by crystalattice

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Airport Log program using 3D linked List : problem reading from file batrsau C Programming Language 11 29-Feb-2008 07:44
Thread synchronization Assignment help!! rossi143 C Programming Language 1 25-Mar-2007 20:10
CD burner wont burn!! robertli55 Computer Hardware Forum 1 18-Jun-2004 10:53
Yet another CD burner problem: Lite-On LSC-24082K Erwin Computer Hardware Forum 1 22-May-2004 11:28
c++/cgi program can't open file in user dir mikenowo Apache Web Server Forum 2 04-Mar-2004 19:33

Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The

All times are GMT -6. The time now is 22:46.


vBulletin, Copyright © 2000 - 2008, Jelsoft Enterprises Ltd.