1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

[Help] Upload file and read to string.

Discussion in 'PHP & Perl' started by Ampix0, Sep 12, 2013.

  1. Ampix0

    Ampix0 Power Member

    Joined:
    Jan 10, 2012
    Messages:
    525
    Likes Received:
    60
    Home Page:
    I am new to PHP and I am creating my first real tool for myself. I am on shared hosting so im not sure about some of the file stuff but basically here is what I have.

    Code:
    <?php
    
    
    $regexstr = "(?<=FN:)(.*)(?=\n+)";
    //RESTRICT TO VCARD ONLY
    if ($_FILES["file"]["type"] == "text/x-vcard") {
    
    
        if ($_FILES["file"]["error"] > 0)
          {
              echo "Error: " . $_FILES["file"]["error"] . "<br>";
          }
        else
          {
              echo "Upload: " . $_FILES["file"]["name"] . "<br>";
              echo "Type: " . $_FILES["file"]["type"] . "<br>";
              echo "Size: " . ($_FILES["file"]["size"] / 1024) . " kB<br>";
              echo "Stored in: " . $_FILES["file"]["tmp_name"];
    
    
              //FILE UPLOADED
              $vcf = file_get_contents($FILES["file"]["tmp_name"]);
              echo $vcf;
    
    
          }
          
    
    
    
    
    
    
    //IF STATEMENT TO CHECK TYPE
    }
    else{
        echo "You may only upload .vcf files.";
    }
    ?>
    

    And instead of echoing the contents of the file I get this.

    Is the temp file already deleted? So I need to move it before reading it? Is there a permission issue?
     
  2. tripper_john_md

    tripper_john_md Newbie

    Joined:
    Feb 21, 2011
    Messages:
    40
    Likes Received:
    35
    Location:
    Southern Germany
    You are missing an underscore ;)