This week only. Pastebin PRO Accounts Christmas Special! Don't miss out!Want more features on Pastebin? Sign Up, it's FREE!
Guest

Untitled

By: a guest on Jul 14th, 2011  |  syntax: PHP  |  size: 0.90 KB  |  views: 92  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. // $fileData is a uploaded file
  2. // I uploaded a jpeg and a tar.gz file and get NO error
  3.  
  4. ob_start();
  5. if (($handle = fopen($fileData['tmp_name'], "r")) !== FALSE) {
  6.     while (($data = fgetcsv($handle, 1000, ",")) !== FALSE) {
  7.         $num = count($data);
  8.         echo "<p> $num fields in line $row: <br /></p>\n";
  9.         $row++;
  10.         for ($c=0; $c < $num; $c++) {
  11.             echo $data[$c] . "<br />\n";
  12.         }
  13.     }
  14. fclose($handle);
  15. return ob_get_clean();
  16.  
  17. // Sample Output
  18.  
  19. /*
  20.  
  21. 1 fields in line :
  22.  
  23. JFIF��@ExifMM*�i�@�@��C   
  24.  
  25. 1 fields in line 1:
  26.  
  27.     
  28.        
  29.  
  30. 1 fields in line 2:
  31.  
  32.       
  33. 
  34.  ��C  ��@@"��     
  35.  
  36. 1 fields in line 3:
  37.  
  38. �}!1AQa"q2���#B��R��$3br�  
  39.  
  40. */
clone this paste RAW Paste Data