Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Upload text file, read, then download result

Status
Not open for further replies.

s0crates9

Technical User
Jun 18, 2005
70
0
0
US
Is there any simple way to take an uploaded file, place it into an array, read line by line and then append it to a variable, finally exporting a textfile download with the results?

For example:
1) user uploads text file with 20 line items including words like:
apple
orange
pear
banana
etc.

2) the file is then read in php and is appended to a pre-defined variable such as: "the fruit is " + line item.

3) the file is then offered back to the user as a txt file with the lines 1-20 like:
the fruit is apple
the fruit is orange
the fruit is pear
etc...

Thanks, I've been trying all sorts of methods and none even spit out the results of the file. I figured I am doing something completely wrong.

Thanks in advance!

Web site design, internet marketing, SEO and business solutions company.
 
Everything you want to do is in the PHP online manual.

First, take a look at the PHP manual section on Handling File Uploads.

Then set the headers on the reply. See the PHP online manual entry for header(), paying particular attention to the last example code on the page before the beginning of user-supplied comments.

Then open the file and start reading lines from the file. See the PHP online manual entry for fgets(), paying attention to the example code.

Then you're going to have to know how to print out the output. See print().



Want the best answers? Ask the best questions! TANSTAAFL!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top