title: using fopen on uploaded file with php
body: <p>Im uploading a file, and then attempting to use fgetcsv to do things to it.</p>
  
  <p>This is my script below. Everything was working fine before i added the file upload portions. Now its not showing any errors, its just not displaying the uploaded data.</p>
  
  <p>Im getting my "file uploaded" notice, and the file is saving properly, but the counter for number of entries is showing 0.</p>
  
  <pre><code>if(isset($_FILES[csvgo])){
  
      $tmp = $_FILES[csvgo][tmp_name];
  
      $name = "temp.csv";
  
      $tempdir = "csvtemp/";
  
      if(move_uploaded_file($tmp, $tempdir.$name)){ echo "file uploaded&lt;br&gt;"; }
  
      $csvfile = $tempdir.$name;
  
      $fh = fopen($csvfile, 'r');
      $headers = fgetcsv($fh);
      $data = array();
      while (! feof($fh))
      {
          $row = fgetcsv($fh);
          if (!empty($row))
          {
              $obj = new stdClass;
              foreach ($row as $i =&gt; $value)
              {
                  $key = $headers[$i];
                  $obj-&gt;$key = $value;
              }
              $data[] = $obj;
          }
      }
      fclose($fh);
  
      $c=0;
  
      foreach($data AS $key){
  
              $c++;
  
              $phone = $key-&gt;PHONE;
  
              $fax = $key-&gt;Fax;
  
              $email = $key-&gt;Email;
  
              // do things with the data here
  
      }
  
      echo "$c entries &lt;br&gt;";
  }
  </code></pre>