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

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • lka527
    New Member
    • Apr 2010
    • 15

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

    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?

    Code:
    <?php
     $fileName = $_FILES['fileHandle']['name'];
    
    move_uploaded_file($_FILES["fileToUpload"]["tmp_name"],
      "C:/upload/" . $_FILES["fileToUpload"]["name"]);
    
     if ($_FILES["fileToUpload"]["error"] > 0)
        {
        echo "Apologies, an error has occurred.";
        echo "Error Code: " . $_FILES["fileToUpload"]["error"];
        }
     else
        {
    
        move_uploaded_file($_FILES["fileToUpload"]["tmp_name"],
    	  "C:/upload/" . $_FILES["fileToUpload"]["name"]);
    	}
    
    
      //  $file = fopen($fileName, "r") or exit ("Unable to open file!");
     
    while(!feof($_FILES))
    {
     
        $line = fgets($_FILES); // Read a line.
    
     
    //escape if the line is empty
            if (trim($line) == "")
                continue;
    //explode from the :
            $fields = explode(":", $line, 2);
     
            echo "<b>$fields[0]</b>";
     
    //checks if second part exists 
            if (isset($fields[1]))
                echo " : $fields[1]";
     
            echo "<br/>";
    
    }
    
        fclose($file);
    ?>
  • blur0224
    New Member
    • Apr 2010
    • 1

    #2
    Is the problem with the uploading or with displaying the information after it's uploaded?

    Comment

    • lka527
      New Member
      • Apr 2010
      • 15

      #3
      Originally posted by blur0224
      Is the problem with the uploading or with displaying the information after it's uploaded?
      it's uploading file and displaying the file I just uploaded..!!

      Comment

      Working...