473,385 Members | 1,642 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Urgent Question!! on PHP!! It's simple!

15
Hi all,
I have a question about the code.
I am working on this code to let others to upload their text files in the same format. (having category name and display the answer after : (colon)..
So, I am trying to let people to be able to upload their text file and go through the code that filters (parses) out the contents I want (what I want is showing the contents after the colon..) Can anyone please help me out?

Expand|Select|Wrap|Line Numbers
  1. <?php
  2.  $fileName = $_FILES['fileHandle']['name'];
  3.  
  4. move_uploaded_file($_FILES["fileToUpload"]["tmp_name"],
  5.   "C:/upload/" . $_FILES["fileToUpload"]["name"]);
  6.  
  7.  if ($_FILES["fileToUpload"]["error"] > 0)
  8.     {
  9.     echo "Apologies, an error has occurred.";
  10.     echo "Error Code: " . $_FILES["fileToUpload"]["error"];
  11.     }
  12.  else
  13.     {
  14.  
  15.     move_uploaded_file($_FILES["fileToUpload"]["tmp_name"],
  16.       "C:/upload/" . $_FILES["fileToUpload"]["name"]);
  17.     }
  18.  
  19.  
  20.   //  $file = fopen($fileName, "r") or exit ("Unable to open file!");
  21.  
  22. while(!feof($_FILES))
  23. {
  24.  
  25.     $line = fgets($_FILES); // Read a line.
  26.  
  27.  
  28. //escape if the line is empty
  29.         if (trim($line) == "")
  30.             continue;
  31. //explode from the :
  32.         $fields = explode(":", $line, 2);
  33.  
  34.         echo "<b>$fields[0]</b>";
  35.  
  36. //checks if second part exists 
  37.         if (isset($fields[1]))
  38.             echo " : $fields[1]";
  39.  
  40.         echo "<br/>";
  41.  
  42. }
  43.  
  44.     fclose($file);
  45. ?>
  46.  
  47.  
Apr 19 '10 #1
2 1181
Is the problem with the uploading or with displaying the information after it's uploaded?
Apr 20 '10 #2
lka527
15
@blur0224
it's uploading file and displaying the file I just uploaded..!!
Apr 20 '10 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: djwyldeone | last post by:
Ok this may be a dumb question to some but for the first time this evening I have to access dBASE file through ODBC.. I'm trying to do simple queries of SELECT * FROM ??? however I can't for the...
1
by: Leo Muller | last post by:
I am running webservers in a web farm (multiple servers), and I want to use the viewstate. I do not want to disable the viewstate encryption check. I also run multiple sites on the same webservers....
13
by: comp.lang.php | last post by:
Other: <input name="school_type_other" size="30" maxlength="75" value="<?php if ($_POST) echo $_POST; else echo str_replace('"', '&quot;', str_replace('\\', '', $result->school_type_other)); ...
3
by: ricolee99 | last post by:
Hi everyone, I have a problem that i have been trying to solve for awhile. I'm given a code where the purpose is to create a general dataset mapper. Given any dataset, i have a class,...
7
by: Ivan Marsh | last post by:
Hey Folks, I'm having a heck of a time wrapping mind around AJAX. Anyone know of a simple, straight-forward example for pulling a simple query from mysql with PHP using AJAX? As I...
2
by: Martin | last post by:
Hello, We are in the process of putting together an A class PHP Development team(ecommerce / billing applications) for a project in the Bay Area. Reqt. details: ReqId : Req-3616 - Senior PHP...
2
by: runway27 | last post by:
presently there is a table which records information about users enquiring for fares to a particular destination. in the existing report which is a php file when a particular date is selected...
11
by: rich | last post by:
I'm having a tough time figuring out which of these two options are best. This is a matter of processing my data in PHP, vs MySQL. Usually that's a no brainer, but I have a couple gotchyas here...
1
by: bnashenas1984 | last post by:
Hi everyone When I started to make my own online store I thought the payment part would be easiest part. Well I was wrong. I'v been googling alot but I can't find any way to safely accept...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.